Commit e39ccaa2ccf6817488038111a9b72eb3007af76c
Committed by
GitHub
1 parent
30a2d19d
[2.5] Improved login by params to support nagivation to different dashboards (#2702)
* Improved login by params * Fix * Removed incorrect redirect * Refactoring
Showing
3 changed files
with
22 additions
and
8 deletions
... | ... | @@ -386,6 +386,26 @@ function UserService($http, $q, $rootScope, adminService, dashboardService, time |
386 | 386 | deferred.reject(); |
387 | 387 | } |
388 | 388 | procceedJwtTokenValidate(); |
389 | + } else if (locationSearch.username && locationSearch.password) { | |
390 | + var user = {}; | |
391 | + user.name = locationSearch.username; | |
392 | + user.password = locationSearch.password; | |
393 | + $location.search('username', null); | |
394 | + $location.search('password', null); | |
395 | + | |
396 | + loginService.login(user).then(function success(response) { | |
397 | + var token = response.data.token; | |
398 | + var refreshToken = response.data.refreshToken; | |
399 | + try { | |
400 | + updateAndValidateToken(token, 'jwt_token', false); | |
401 | + updateAndValidateToken(refreshToken, 'refresh_token', false); | |
402 | + } catch (e) { | |
403 | + deferred.reject(); | |
404 | + } | |
405 | + procceedJwtTokenValidate(); | |
406 | + }, function fail() { | |
407 | + deferred.reject(); | |
408 | + }); | |
389 | 409 | } else { |
390 | 410 | procceedJwtTokenValidate(); |
391 | 411 | } | ... | ... |
... | ... | @@ -20,7 +20,7 @@ import logoSvg from '../../svg/logo_title_white.svg'; |
20 | 20 | /* eslint-enable import/no-unresolved, import/default */ |
21 | 21 | |
22 | 22 | /*@ngInject*/ |
23 | -export default function LoginController(toast, loginService, userService, types, $state, $stateParams/*, $rootScope, $log, $translate*/) { | |
23 | +export default function LoginController(toast, loginService, userService, types, $state/*, $rootScope, $log, $translate*/) { | |
24 | 24 | var vm = this; |
25 | 25 | |
26 | 26 | vm.logoSvg = logoSvg; |
... | ... | @@ -32,12 +32,6 @@ export default function LoginController(toast, loginService, userService, types, |
32 | 32 | |
33 | 33 | vm.login = login; |
34 | 34 | |
35 | - if ($stateParams.username && $stateParams.password) { | |
36 | - vm.user.name = $stateParams.username; | |
37 | - vm.user.password = $stateParams.password; | |
38 | - doLogin(); | |
39 | - } | |
40 | - | |
41 | 35 | function doLogin() { |
42 | 36 | loginService.login(vm.user).then(function success(response) { |
43 | 37 | var token = response.data.token; | ... | ... |
... | ... | @@ -25,7 +25,7 @@ import createPasswordTemplate from './create-password.tpl.html'; |
25 | 25 | /*@ngInject*/ |
26 | 26 | export default function LoginRoutes($stateProvider) { |
27 | 27 | $stateProvider.state('login', { |
28 | - url: '/login?username&password', | |
28 | + url: '/login', | |
29 | 29 | module: 'public', |
30 | 30 | views: { |
31 | 31 | "@": { | ... | ... |