1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

convert to identityserver auth

This commit is contained in:
Kyle Spearrin
2017-01-17 23:07:46 -05:00
parent f84bfcb19a
commit 6bb6c7074b
6 changed files with 202 additions and 83 deletions

View File

@@ -12,25 +12,25 @@
cryptoService.hashPassword(masterPassword, key, function (hashedPassword) {
var request = new TokenRequest(email, hashedPassword);
apiService.postToken(request, function (response) {
if (!response || !response.token) {
apiService.postIdentityToken(request, function (response) {
if (!response || !response.accessToken) {
return;
}
tokenService.setToken(response.token, function () {
tokenService.setTokens(response.accessToken, response.refreshToken, function () {
cryptoService.setKey(key, function () {
cryptoService.setKeyHash(hashedPassword, function () {
if (response.profile) {
userService.setUserId(response.profile.id, function () {
userService.setEmail(response.profile.email, function () {
if (tokenService.isTwoFactorScheme()) {
deferred.resolve(response);
}
else {
userService.setUserId(tokenService.getUserId(), function () {
userService.setEmail(tokenService.getEmail(), function () {
chrome.runtime.sendMessage({ command: 'loggedIn' });
deferred.resolve(response);
});
});
}
else {
deferred.resolve(response);
}
});
});
});