mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
support user encryption key
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
.module('bit.accounts')
|
||||
|
||||
.controller(
|
||||
'accountsRegisterController',
|
||||
function ($scope, $state, cryptoService, toastr, $q, apiService, utilsService, $analytics, i18nService) {
|
||||
'accountsRegisterController',
|
||||
function ($scope, $state, cryptoService, toastr, $q, apiService, utilsService, $analytics, i18nService) {
|
||||
$scope.i18n = i18nService;
|
||||
|
||||
$scope.model = {};
|
||||
@@ -45,15 +45,17 @@
|
||||
|
||||
function registerPromise(key, masterPassword, email, hint) {
|
||||
return $q(function (resolve, reject) {
|
||||
cryptoService.hashPassword(masterPassword, key, function (hashedPassword) {
|
||||
var request = new RegisterRequest(email, hashedPassword, hint);
|
||||
apiService.postRegister(request,
|
||||
function () {
|
||||
resolve();
|
||||
},
|
||||
function (error) {
|
||||
reject(error);
|
||||
});
|
||||
cryptoService.makeEncKey(key).then(function (encKey) {
|
||||
cryptoService.hashPassword(masterPassword, key, function (hashedPassword) {
|
||||
var request = new RegisterRequest(email, hashedPassword, hint, encKey.encryptedString);
|
||||
apiService.postRegister(request,
|
||||
function () {
|
||||
resolve();
|
||||
},
|
||||
function (error) {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
var userService = $injector.get('userService');
|
||||
var cryptoService = $injector.get('cryptoService');
|
||||
|
||||
cryptoService.getKey(function (key) {
|
||||
cryptoService.getKey().then(function (key) {
|
||||
userService.isAuthenticated(function (isAuthenticated) {
|
||||
if (isAuthenticated) {
|
||||
if (!key) {
|
||||
|
||||
@@ -24,12 +24,9 @@
|
||||
cryptoService.setKey(key, function () {
|
||||
cryptoService.setKeyHash(hashedPassword, function () {
|
||||
userService.setUserIdAndEmail(tokenService.getUserId(), tokenService.getEmail(), function () {
|
||||
if (!response.privateKey) {
|
||||
loggedIn(deferred);
|
||||
return;
|
||||
}
|
||||
|
||||
cryptoService.setEncPrivateKey(response.privateKey).then(function () {
|
||||
cryptoService.setEncKey(response.key).then(function () {
|
||||
return cryptoService.setEncPrivateKey(response.privateKey);
|
||||
}).then(function () {
|
||||
loggedIn(deferred);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user