mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
fix callbacks for user service methods
This commit is contained in:
parent
2211c569d7
commit
e3dea4084f
@ -436,19 +436,21 @@ var bg_isBackground = true,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bg_userService.isAuthenticated(function (isAuthenticated) {
|
var isAuthenticated;
|
||||||
bg_cryptoService.getKey().then(function (key) {
|
bg_userService.isAuthenticated().then(function (theIsAuthenticated) {
|
||||||
var suffix = '';
|
isAuthenticated = theIsAuthenticated;
|
||||||
if (!isAuthenticated) {
|
return bg_cryptoService.getKey();
|
||||||
suffix = '_gray';
|
}).then(function (key) {
|
||||||
}
|
var suffix = '';
|
||||||
else if (!key) {
|
if (!isAuthenticated) {
|
||||||
suffix = '_locked';
|
suffix = '_gray';
|
||||||
}
|
}
|
||||||
|
else if (!key) {
|
||||||
|
suffix = '_locked';
|
||||||
|
}
|
||||||
|
|
||||||
actionSetIcon(chrome.browserAction, suffix);
|
actionSetIcon(chrome.browserAction, suffix);
|
||||||
actionSetIcon(bg_sidebarAction, suffix);
|
actionSetIcon(bg_sidebarAction, suffix);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function actionSetIcon(theAction, suffix) {
|
function actionSetIcon(theAction, suffix) {
|
||||||
|
@ -23,20 +23,22 @@ angular
|
|||||||
var userService = $injector.get('userService');
|
var userService = $injector.get('userService');
|
||||||
var cryptoService = $injector.get('cryptoService');
|
var cryptoService = $injector.get('cryptoService');
|
||||||
|
|
||||||
cryptoService.getKey().then(function (key) {
|
var key;
|
||||||
userService.isAuthenticated(function (isAuthenticated) {
|
cryptoService.getKey().then(function (theKey) {
|
||||||
if (isAuthenticated) {
|
key = theKey;
|
||||||
if (!key) {
|
return userService.isAuthenticated();
|
||||||
$state.go('lock');
|
}).then(function (isAuthenticated) {
|
||||||
}
|
if (isAuthenticated) {
|
||||||
else {
|
if (!key) {
|
||||||
$state.go('tabs.current');
|
$state.go('lock');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$state.go('home');
|
$state.go('tabs.current');
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
else {
|
||||||
|
$state.go('home');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -269,7 +271,7 @@ angular
|
|||||||
|
|
||||||
stateService.init();
|
stateService.init();
|
||||||
|
|
||||||
$transitions.onStart({}, function(trans) {
|
$transitions.onStart({}, function (trans) {
|
||||||
const $state = trans.router.stateService;
|
const $state = trans.router.stateService;
|
||||||
const toState = trans.to();
|
const toState = trans.to();
|
||||||
|
|
||||||
@ -284,7 +286,7 @@ angular
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
userService.isAuthenticated((isAuthenticated) => {
|
userService.isAuthenticated().then((isAuthenticated) => {
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
var obj = {};
|
var obj = {};
|
||||||
obj[constantsService.lastActiveKey] = (new Date()).getTime();
|
obj[constantsService.lastActiveKey] = (new Date()).getTime();
|
||||||
|
@ -24,7 +24,7 @@ angular
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.submit = function () {
|
$scope.submit = function () {
|
||||||
userService.getEmail(function (email) {
|
userService.getEmail().then(function (email) {
|
||||||
var key = cryptoService.makeKey($scope.masterPassword, email);
|
var key = cryptoService.makeKey($scope.masterPassword, email);
|
||||||
var keyHash;
|
var keyHash;
|
||||||
cryptoService.hashPassword($scope.masterPassword, key).then(function (theKeyHash) {
|
cryptoService.hashPassword($scope.masterPassword, key).then(function (theKeyHash) {
|
||||||
|
@ -22,7 +22,7 @@ angular
|
|||||||
function checkPassword() {
|
function checkPassword() {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
userService.getEmail(function (email) {
|
userService.getEmail().then(function (email) {
|
||||||
var key = cryptoService.makeKey($scope.masterPassword, email);
|
var key = cryptoService.makeKey($scope.masterPassword, email);
|
||||||
var keyHash;
|
var keyHash;
|
||||||
cryptoService.hashPassword($scope.masterPassword, key).then(function (theKeyHash) {
|
cryptoService.hashPassword($scope.masterPassword, key).then(function (theKeyHash) {
|
||||||
|
@ -21,7 +21,7 @@ function initSyncService() {
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
self.syncStarted();
|
self.syncStarted();
|
||||||
self.userService.isAuthenticated(function (isAuthenticated) {
|
self.userService.isAuthenticated().then(function (isAuthenticated) {
|
||||||
if (!isAuthenticated) {
|
if (!isAuthenticated) {
|
||||||
self.syncCompleted(false);
|
self.syncCompleted(false);
|
||||||
callback(false);
|
callback(false);
|
||||||
|
@ -31,7 +31,6 @@ export default class UserService {
|
|||||||
return UtilsService.saveObjToStorage(Keys.stamp, stamp);
|
return UtilsService.saveObjToStorage(Keys.stamp, stamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: callbacks
|
|
||||||
async getUserId(): Promise<string> {
|
async getUserId(): Promise<string> {
|
||||||
if (this.userId != null) {
|
if (this.userId != null) {
|
||||||
return this.userId;
|
return this.userId;
|
||||||
@ -41,7 +40,6 @@ export default class UserService {
|
|||||||
return this.userId;
|
return this.userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: callbacks
|
|
||||||
async getEmail(): Promise<string> {
|
async getEmail(): Promise<string> {
|
||||||
if (this.email != null) {
|
if (this.email != null) {
|
||||||
return this.email;
|
return this.email;
|
||||||
@ -70,7 +68,6 @@ export default class UserService {
|
|||||||
this.userId = this.email = this.stamp = null;
|
this.userId = this.email = this.stamp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: fix callbacks
|
|
||||||
async isAuthenticated(): Promise<boolean> {
|
async isAuthenticated(): Promise<boolean> {
|
||||||
const token = await this.tokenService.getToken();
|
const token = await this.tokenService.getToken();
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user