Add development config for automatique login
Change-Id: I12318c7e0b1bfd8630639f2ec8e3478121f1e856
This commit is contained in:
parent
981198439a
commit
daf0cfc65f
2
.gitignore
vendored
2
.gitignore
vendored
@ -20,3 +20,5 @@ dist/
|
||||
.tmp/
|
||||
|
||||
app/components/live/live.js
|
||||
|
||||
app/components/config/developmentConfig.json
|
||||
|
@ -9,7 +9,11 @@ angular.module('bansho.authentication', [])
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('LoginController', ['$scope', '$rootScope', '$location', 'authService', function ($scope, $rootScope, $location, authService) {
|
||||
.controller('LoginController', ['$scope', '$rootScope', '$location', 'authService', 'configManager', function ($scope, $rootScope, $location, authService, configManager) {
|
||||
var login = function (credentials) {
|
||||
authService.login(credentials);
|
||||
};
|
||||
|
||||
$scope.credentials = {
|
||||
'auth': {
|
||||
'tenantName': '',
|
||||
@ -20,9 +24,28 @@ angular.module('bansho.authentication', [])
|
||||
}
|
||||
};
|
||||
|
||||
$scope.login = function (credentials) {
|
||||
authService.login(credentials);
|
||||
};
|
||||
$scope.login = function() {
|
||||
login($scope.credentials);
|
||||
};
|
||||
|
||||
configManager.loadDevelopmentConfig().then(function () {
|
||||
var devConfig = configManager.getDevelopmentConfig();
|
||||
if (devConfig.env === 'development') {
|
||||
login({
|
||||
'auth': {
|
||||
'tenantName': '',
|
||||
'passwordCredentials': {
|
||||
'username': devConfig.username,
|
||||
'password': devConfig.password
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}, function () {
|
||||
// Development config failed
|
||||
});
|
||||
|
||||
}])
|
||||
|
||||
.factory('authService', ['$http', '$location', '$rootScope', 'session', 'configManager', function ($http, $location, $rootScope, session, configManager) {
|
||||
|
@ -4,7 +4,27 @@
|
||||
angular.module('bansho.config', [])
|
||||
|
||||
.service('configManager', ['$http', '$q', function ($http, $q) {
|
||||
var config = {};
|
||||
var config = {},
|
||||
developmentConfig = {};
|
||||
|
||||
this.loadDevelopmentConfig = function() {
|
||||
var promise = $q.defer();
|
||||
|
||||
$http.get('components/config/developmentConfig.json')
|
||||
.success(function (config) {
|
||||
developmentConfig = config;
|
||||
promise.resolve();
|
||||
})
|
||||
.error(function() {
|
||||
promise.reject();
|
||||
});
|
||||
|
||||
return promise.promise;
|
||||
};
|
||||
|
||||
this.getDevelopmentConfig = function () {
|
||||
return developmentConfig;
|
||||
};
|
||||
|
||||
this.loadByTemplate = function (templateName, destination) {
|
||||
var viewsConfig = config.data;
|
||||
|
5
app/components/config/developmentConfig.json
Normal file
5
app/components/config/developmentConfig.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"env": "development",
|
||||
"username":"",
|
||||
"password":""
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user