1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-22 11:45:59 +01:00

Validation of forms

This commit is contained in:
Kyle Spearrin 2016-09-22 12:50:27 -04:00
parent 24db219dc3
commit 985dba1555
16 changed files with 74 additions and 11 deletions

View File

@ -7,6 +7,11 @@
$scope.submitPromise = null;
$scope.submit = function (model) {
if (!model.email) {
toastr.error('Email is required.');
return;
}
var request = new PasswordHintRequest(model.email);
$scope.submitPromise = hintPromise(request);
$scope.submitPromise.then(function () {

View File

@ -17,6 +17,15 @@
$scope.loginPromise = null;
$scope.login = function (model) {
if (!model.email) {
toastr.error('Email is required.');
return;
}
if (!model.masterPassword) {
toastr.error('Master password is required.');
return;
}
$scope.loginPromise = loginService.logIn(model.email, model.masterPassword);
$scope.loginPromise.then(function () {

View File

@ -7,6 +7,11 @@
$scope.loginPromise = null;
$scope.login = function (model) {
if (!model.code) {
toastr.error('Verification code is required.');
return;
}
$scope.loginPromise = loginService.logInTwoFactor(model.code);
$scope.loginPromise.then(function () {
$state.go('tabs.vault', { animation: 'in-slide-left' });

View File

@ -7,6 +7,19 @@
$scope.submitPromise = null;
$scope.submit = function (model) {
if (!model.email) {
toastr.error('Email is required.');
return;
}
if (!model.masterPassword) {
toastr.error('Master password is required.');
return;
}
if (model.masterPassword !== model.masterPasswordRetype) {
toastr.error('Master password confirmation does not match.');
return;
}
var email = model.email.toLowerCase();
var key = cryptoService.makeKey(model.masterPassword, email);
$scope.submitPromise = registerPromise(key, model.masterPassword, email, model.hint);

View File

@ -1,4 +1,4 @@
<form name="theForm" ng-submit="theForm.$valid && submit(model)" bit-form="submitPromise">
<form name="theForm" ng-submit="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>

View File

@ -1,4 +1,4 @@
<form name="theForm" ng-submit="theForm.$valid && login(model)" bit-form="loginPromise">
<form name="theForm" ng-submit="login(model)" bit-form="loginPromise">
<div class="header">
<div class="left">
<a ui-sref="home({animation: 'out-slide-down'})">Cancel</a>
@ -21,7 +21,8 @@
<div class="list-section-item list-section-item-icon-input">
<i class="fa fa-lock fa-lg fa-fw"></i>
<label for="master-password" class="sr-only">Master Password</label>
<input id="master-password" type="password" name="MasterPassword" placeholder="Master Password" ng-model="model.masterPassword">
<input id="master-password" type="password" name="MasterPassword" placeholder="Master Password"
ng-model="model.masterPassword">
</div>
</div>
</div>

View File

@ -1,4 +1,4 @@
<form name="theForm" ng-submit="theForm.$valid && login(model)" bit-form="loginPromise">
<form name="theForm" ng-submit="login(model)" bit-form="loginPromise">
<div class="header">
<div class="left">
<a ui-sref="login({animation: 'out-slide-right'})"><i class="fa fa-chevron-left"></i> Log In</a>

View File

@ -1,4 +1,4 @@
<form name="theForm" ng-submit="theForm.$valid && submit(model)" bit-form="submitPromise">
<form name="theForm" ng-submit="submit(model)" bit-form="submitPromise">
<div class="header">
<div class="left">
<a ui-sref="home({animation: 'out-slide-down'})">Cancel</a>

View File

@ -7,6 +7,11 @@ angular
$scope.savePromise = null;
$scope.save = function (model) {
if (!model.name) {
toastr.error('Name is required.');
return;
}
$scope.savePromise = $q.when(folderService.encrypt(model)).then(function (folderModel) {
var folder = new Folder(folderModel, true);
return $q.when(folderService.saveWithServer(folder)).then(function (folder) {

View File

@ -14,6 +14,11 @@
$scope.savePromise = null;
$scope.save = function (model) {
if (!model.name) {
toastr.error('Name is required.');
return;
}
$scope.savePromise = $q.when(folderService.encrypt(model)).then(function (folderModel) {
var folder = new Folder(folderModel, true);
return $q.when(folderService.saveWithServer(folder)).then(function (folder) {

View File

@ -1,4 +1,4 @@
<form name="theForm" ng-submit="theForm.$valid && save(folder)" bit-form="savePromise">
<form name="theForm" ng-submit="save(folder)" bit-form="savePromise">
<div class="header">
<div class="left">
<a ui-sref="folders({animation: 'out-slide-down'})">Cancel</a>

View File

@ -1,4 +1,4 @@
<form name="theForm" ng-submit="theForm.$valid && save(folder)" bit-form="savePromise">
<form name="theForm" ng-submit="save(folder)" bit-form="savePromise">
<div class="header">
<div class="left">
<a ui-sref="folders({animation: 'out-slide-down'})">Cancel</a>

View File

@ -1,7 +1,8 @@
angular
.module('bit.vault')
.controller('vaultAddSiteController', function ($scope, $state, $stateParams, siteService, folderService, cryptoService, $q, toastr) {
.controller('vaultAddSiteController', function ($scope, $state, $stateParams, siteService, folderService,
cryptoService, $q, toastr) {
var returnScrollY = $stateParams.returnScrollY;
var returnSearchText = $stateParams.returnSearchText;
var fromCurrent = $stateParams.fromCurrent || $stateParams.uri !== null;
@ -30,6 +31,15 @@
$scope.savePromise = null;
$scope.save = function (model) {
if (!model.name) {
toastr.error('Name is required.');
return;
}
if (!model.password) {
toastr.error('Password is required.');
return;
}
$scope.savePromise = $q.when(siteService.encrypt(model)).then(function (siteModel) {
var site = new Site(siteModel, true);
return $q.when(siteService.saveWithServer(site)).then(function (site) {

View File

@ -1,7 +1,8 @@
angular
.module('bit.vault')
.controller('vaultEditSiteController', function ($scope, $state, $stateParams, siteService, folderService, cryptoService, $q, toastr, SweetAlert) {
.controller('vaultEditSiteController', function ($scope, $state, $stateParams, siteService, folderService,
cryptoService, $q, toastr, SweetAlert) {
var returnScrollY = $stateParams.returnScrollY;
var returnSearchText = $stateParams.returnSearchText;
var siteId = $stateParams.siteId;
@ -30,6 +31,15 @@ angular
$scope.savePromise = null;
$scope.save = function (model) {
if (!model.name) {
toastr.error('Name is required.');
return;
}
if (!model.password) {
toastr.error('Password is required.');
return;
}
$scope.savePromise = $q.when(siteService.encrypt(model)).then(function (siteModel) {
var site = new Site(siteModel, true);
return $q.when(siteService.saveWithServer(site)).then(function (site) {

View File

@ -1,4 +1,4 @@
<form name="theForm" ng-submit="theForm.$valid && save(site)" bit-form="savePromise">
<form name="theForm" ng-submit="save(site)" bit-form="savePromise">
<div class="header">
<div class="left">
<a ng-click="close()" href="">Cancel</a>

View File

@ -1,4 +1,4 @@
<form name="theForm" ng-submit="theForm.$valid && save(site)" bit-form="savePromise">
<form name="theForm" ng-submit="save(site)" bit-form="savePromise">
<div class="header">
<div class="left">
<a ng-click="close()" href="">Cancel</a>