password hint

This commit is contained in:
Kyle Spearrin 2016-09-20 17:47:21 -04:00
parent 797a18b46a
commit 0219068bb6
14 changed files with 115 additions and 22 deletions

View File

@ -28,8 +28,8 @@ var RegisterRequest = function () {
this.masterPasswordHint = null;
};
var PasswordHintRequest = function () {
this.email = null;
var PasswordHintRequest = function (email) {
this.email = email;
};
var TokenTwoFactorRequest = function () {

View File

@ -1,4 +1,4 @@
var CipherResponse = function (response) {
var CipherResponse = function (response) {
this.id = response.Id;
this.folderId = response.FolderId;
this.type = response.Type;
@ -24,7 +24,7 @@ var SiteResponse = function (response) {
this.favorite = response.Favorite;
this.revisionDate = response.RevisionDate;
if(response.Folder) {
if (response.Folder) {
this.folder = new FolderResponse(response.Folder);
}
};
@ -51,8 +51,10 @@ var ListResponse = function (data) {
};
var ErrorResponse = function (response) {
this.message = response.responseJSON.Message;
this.validationErrors = response.responseJSON.ValidationErrors;
if (response.responseJSON) {
this.message = response.responseJSON.Message;
this.validationErrors = response.responseJSON.ValidationErrors;
}
this.statusCode = response.status;
};

View File

@ -0,0 +1,28 @@
angular
.module('bit.accounts')
.controller('accountsHintController', function ($scope, $state, apiService, toastr, $q) {
popupUtils.initListSectionItemListeners();
$scope.submitPromise = null;
$scope.submit = function (model) {
var request = new PasswordHintRequest(model.email);
$scope.submitPromise = hintPromise(request);
$scope.submitPromise.then(function () {
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);
});
});
}
});

View File

@ -5,7 +5,7 @@
popupUtils.initListSectionItemListeners();
$scope.loginPromise = null;
$scope.login = function (model, form) {
$scope.login = function (model) {
$scope.loginPromise = loginService.logIn(model.email, model.masterPassword);
$scope.loginPromise.then(function () {

View File

@ -1,2 +1,2 @@
angular
.module('bit.accounts', []);
.module('bit.accounts', ['toastr']);

View File

@ -0,0 +1,28 @@
<form name="theForm" ng-submit="theForm.$valid && submit(model)" bit-form="submitPromise">
<div class="header">
<div class="left">
<a ui-sref="login({animation: 'out-slide-right'})"><i class="fa fa-chevron-left"></i> Log In</a>
</div>
<div class="right">
<button type="submit" class="btn btn-link" ng-show="!theForm.$loading">Submit</button>
<i class="fa fa-spinner fa-lg" ng-show="theForm.$loading" ng-class="{'fa-spin' : theForm.$loading}"></i>
</div>
<div class="title">Password Hint</div>
</div>
<div class="content">
<div class="list">
<div class="list-section">
<div class="list-section-items">
<div class="list-section-item list-section-item-icon-input">
<i class="fa fa-envelope fa-lg fa-fw"></i>
<label for="email" class="sr-only">Email Address</label>
<input id="email" type="email" name="Email" placeholder="Email Address" ng-model="model.email">
</div>
</div>
<div class="list-section-footer">
Enter your account email address to receive your master password hint.
</div>
</div>
</div>
</div>
</form>

View File

@ -1,4 +1,4 @@
<form name="theForm" ng-submit="theForm.$valid && login(model, theForm)" bit-form="loginPromise">
<form name="theForm" ng-submit="theForm.$valid && login(model)" bit-form="loginPromise">
<div class="header">
<div class="left">
<a ui-sref="home({animation: 'out-slide-down'})">Cancel</a>
@ -27,7 +27,7 @@
</div>
</div>
<p class="text-center">
<a href="#/hint">Get master password hint</a>
<a ui-sref="hint({animation: 'in-slide-left'})">Get master password hint</a>
</p>
</div>
</form>

View File

@ -29,7 +29,7 @@
$urlRouterProvider.otherwise(function ($injector, $location) {
var $state = $injector.get('$state');
$state.go('splash');
$state.go('home');
});
$stateProvider
@ -55,6 +55,13 @@
data: { authorize: false },
params: { animation: null }
})
.state('hint', {
url: '/hint',
controller: 'accountsHintController',
templateUrl: 'app/accounts/views/accountsHint.html',
data: { authorize: false },
params: { animation: null }
})
.state('twoFactor', {
url: '/two-factor',
controller: 'accountsLoginController',

View File

@ -1,2 +1,2 @@
angular
.module('bit.services', ['angular-jwt', 'oitozero.ngSweetAlert']);
.module('bit.services', ['angular-jwt', 'toastr']);

View File

@ -1,7 +1,7 @@
angular
.module('bit.services')
.factory('validationService', function (SweetAlert) {
.factory('validationService', function (toastr) {
var _service = {};
_service.showError = function (data) {
@ -32,13 +32,7 @@
}
if (errors.length) {
SweetAlert.swal({
title: 'Error',
text: errors[0],
type: 'error',
showCancelButton: false,
confirmButtonText: 'Ok'
});
toastr.error(errors[0], 'Errors have occurred');
}
return errors;

View File

@ -19,7 +19,7 @@
}, function (confirmed) {
if (confirmed) {
loginService.logOut(function () {
$state.go('login');
$state.go('home');
});
}
});

View File

@ -1,2 +1,2 @@
angular
.module('bit.tools', ['ngAnimate', 'ngclipboard', 'toastr', 'rzModule']);
.module('bit.tools', ['ngAnimate', 'ngclipboard', 'toastr', 'rzModule', 'oitozero.ngSweetAlert']);

View File

@ -52,6 +52,7 @@
<script src="app/accounts/accountsModule.js"></script>
<script src="app/accounts/accountsLoginController.js"></script>
<script src="app/accounts/accountsHintController.js"></script>
<script src="app/current/currentModule.js"></script>
<script src="app/current/currentController.js"></script>

View File

@ -61,6 +61,39 @@ function initApiService() {
});
};
ApiService.prototype.postPasswordHint = function (request, success, error) {
var self = this;
$.ajax({
type: 'POST',
url: self.baseUrl + '/accounts/password-hint',
data: JSON.stringify(request),
contentType: "application/json; charset=utf-8",
success: function (response) {
success();
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
}
});
};
ApiService.prototype.register = function (request, success, error) {
var self = this;
$.ajax({
type: 'POST',
url: self.baseUrl + '/accounts/register',
data: JSON.stringify(request),
contentType: "application/json; charset=utf-8",
dataType: 'json',
success: function (response) {
success();
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
}
});
};
// Site APIs
ApiService.prototype.getSite = function (id, success, error) {