mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-20 07:40:57 +02:00
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
angular
|
|
.module('bit.accounts')
|
|
|
|
.controller('accountsHintController', function ($scope, $state, apiService, toastr, $q, utilsService,
|
|
$analytics) {
|
|
$scope.model = {};
|
|
|
|
utilsService.initListSectionItemListeners($(document), angular);
|
|
$('#email').focus();
|
|
|
|
$scope.submitPromise = null;
|
|
$scope.submit = function (model) {
|
|
if (!model.email) {
|
|
toastr.error('Email address is required.', 'Errors have occurred');
|
|
return;
|
|
}
|
|
if (model.email.indexOf('@') === -1) {
|
|
toastr.error('Invalid email address.', 'Errors have occurred');
|
|
return;
|
|
}
|
|
|
|
var request = new PasswordHintRequest(model.email);
|
|
$scope.submitPromise = hintPromise(request);
|
|
$scope.submitPromise.then(function () {
|
|
$analytics.eventTrack('Requested Hint');
|
|
toastr.success('We\'ve sent you an email with your master password hint.');
|
|
$state.go('login');
|
|
});
|
|
};
|
|
|
|
function hintPromise(request) {
|
|
return $q(function (resolve, reject) {
|
|
apiService.postPasswordHint(request,
|
|
function () {
|
|
resolve();
|
|
},
|
|
function (error) {
|
|
reject(error);
|
|
});
|
|
});
|
|
}
|
|
});
|