1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

registration

This commit is contained in:
Kyle Spearrin
2016-09-20 19:57:24 -04:00
parent d7d45f3b50
commit ee4548a84a
9 changed files with 124 additions and 20 deletions

View File

@@ -0,0 +1,33 @@
angular
.module('bit.accounts')
.controller('accountsRegisterController', function ($scope, $state, cryptoService, toastr, $q, apiService) {
popupUtils.initListSectionItemListeners();
$('#email').focus();
$scope.submitPromise = null;
$scope.submit = function (model) {
var email = model.email.toLowerCase();
var key = cryptoService.makeKey(model.masterPassword, email);
$scope.submitPromise = registerPromise(key, model.masterPassword, email, model.hint);
$scope.submitPromise.then(function () {
toastr.success('Your new account has been created! You may now log in.');
$state.go('login', { email: email, animation: 'in-slide-left' });
});
};
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);
});
});
});
}
});