[2.5] Improved login by params to support nagivation to different dashboards (#2702)
* Improved login by params * Fix * Removed incorrect redirect * Refactoring
This commit is contained in:
parent
30a2d19d2d
commit
e39ccaa2cc
@ -386,6 +386,26 @@ function UserService($http, $q, $rootScope, adminService, dashboardService, time
|
||||
deferred.reject();
|
||||
}
|
||||
procceedJwtTokenValidate();
|
||||
} else if (locationSearch.username && locationSearch.password) {
|
||||
var user = {};
|
||||
user.name = locationSearch.username;
|
||||
user.password = locationSearch.password;
|
||||
$location.search('username', null);
|
||||
$location.search('password', null);
|
||||
|
||||
loginService.login(user).then(function success(response) {
|
||||
var token = response.data.token;
|
||||
var refreshToken = response.data.refreshToken;
|
||||
try {
|
||||
updateAndValidateToken(token, 'jwt_token', false);
|
||||
updateAndValidateToken(refreshToken, 'refresh_token', false);
|
||||
} catch (e) {
|
||||
deferred.reject();
|
||||
}
|
||||
procceedJwtTokenValidate();
|
||||
}, function fail() {
|
||||
deferred.reject();
|
||||
});
|
||||
} else {
|
||||
procceedJwtTokenValidate();
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ import logoSvg from '../../svg/logo_title_white.svg';
|
||||
/* eslint-enable import/no-unresolved, import/default */
|
||||
|
||||
/*@ngInject*/
|
||||
export default function LoginController(toast, loginService, userService, types, $state, $stateParams/*, $rootScope, $log, $translate*/) {
|
||||
export default function LoginController(toast, loginService, userService, types, $state/*, $rootScope, $log, $translate*/) {
|
||||
var vm = this;
|
||||
|
||||
vm.logoSvg = logoSvg;
|
||||
@ -32,12 +32,6 @@ export default function LoginController(toast, loginService, userService, types,
|
||||
|
||||
vm.login = login;
|
||||
|
||||
if ($stateParams.username && $stateParams.password) {
|
||||
vm.user.name = $stateParams.username;
|
||||
vm.user.password = $stateParams.password;
|
||||
doLogin();
|
||||
}
|
||||
|
||||
function doLogin() {
|
||||
loginService.login(vm.user).then(function success(response) {
|
||||
var token = response.data.token;
|
||||
|
||||
@ -25,7 +25,7 @@ import createPasswordTemplate from './create-password.tpl.html';
|
||||
/*@ngInject*/
|
||||
export default function LoginRoutes($stateProvider) {
|
||||
$stateProvider.state('login', {
|
||||
url: '/login?username&password',
|
||||
url: '/login',
|
||||
module: 'public',
|
||||
views: {
|
||||
"@": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user