1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-23 01:12:19 -05:00

show error on incorrect input

This commit is contained in:
Tankred Hase 2013-10-22 14:59:36 +02:00
parent 1d44993d8b
commit 0e08a31b21
4 changed files with 18 additions and 6 deletions

View File

@ -5,6 +5,7 @@ define(function(require) {
var LoginExistingCtrl = function($scope, $location) {
$scope.buttonEnabled = true;
$scope.incorrect = false;
$scope.confirmPassphrase = function() {
var passphrase = $scope.passphrase,
@ -16,6 +17,7 @@ define(function(require) {
// disable button once loggin has started
$scope.buttonEnabled = false;
$scope.incorrect = false;
unlockCrypto(imapLogin);
function unlockCrypto(callback) {
@ -31,16 +33,14 @@ define(function(require) {
function imapLogin(err) {
if (err) {
$scope.buttonEnabled = true;
console.error(err);
handleError(err);
return;
}
// login to imap backend
appController._emailDao.imapLogin(function(err) {
if (err) {
$scope.buttonEnabled = true;
console.error(err);
handleError(err);
return;
}
onLogin();
@ -48,6 +48,13 @@ define(function(require) {
}
};
function handleError(err) {
$scope.incorrect = true;
$scope.buttonEnabled = true;
$scope.$apply();
console.error(err);
}
function onLogin() {
$location.path('/desktop');
$scope.$apply();

View File

@ -39,6 +39,11 @@
border-style: solid;
border-color: $color-grey-light;
padding: 5px;
outline: none;
}
.error {
border: 1px solid red;
}
}
}

View File

@ -11,7 +11,7 @@
<form>
<div>
<input type="password" ng-model="passphrase" class="passphrase" placeholder="Passphrase" tabindex="1" focus-me="true">
<input type="password" ng-model="passphrase" ng-class="{error:incorrect}" placeholder="Passphrase" tabindex="1" focus-me="true">
</div>
<div>
<button type="submit" ng-click="confirmPassphrase()" class="btn" ng-disabled="!buttonEnabled" tabindex="2">Unlock</button>

View File

@ -13,7 +13,7 @@
<form>
<div>
<input type="password" ng-model="passphrase" placeholder="Enter passphrase" tabindex="1" focus-me="true">
<input type="password" ng-model="confirmation" placeholder="Confirm Passphrase" tabindex="2">
<input type="password" ng-model="confirmation" ng-class="{error: confirmation !== passphrase}" placeholder="Confirm Passphrase" tabindex="2">
</div>
<div>
<button type="submit" ng-click="confirmPassphrase()" class="btn" ng-disabled="!passphrase || passphrase!==confirmation" tabindex="3">Generate keypair</button>