Fix login and authorization token errors

* Remove extraneous quotes when authroization token is retrieved
from a cookie
* Fix thrown error when invalid creds are supplied on login due to
attempt to access property of an undefined value
This commit is contained in:
gconsidine 2017-09-22 17:58:16 -04:00
parent 9e9692971f
commit 4ad2af30cf
No known key found for this signature in database
GPG Key ID: CC78E4D5913BB71D

View File

@ -45,7 +45,13 @@ export default
},
getToken: function () {
return ($rootScope.token) ? $rootScope.token : $cookies.get('token');
if ($rootScope.token) {
return $rootScope.token;
}
let token = $cookies.get('token');
return token ? token.replace(/"/g, '') : undefined;
},
retrieveToken: function (username, password) {
@ -101,7 +107,7 @@ export default
$rootScope.lastPath = '/home';
}
x = Store('sessionTime');
if ($rootScope.current_user) {
if ($rootScope.current_user && x && x[$rootScope.current_user.id]) {
x[$rootScope.current_user.id].loggedIn = false;
}
Store('sessionTime', x);