1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-30 04:42:15 -05:00

handle errors in new device import

This commit is contained in:
Tankred Hase 2013-10-22 17:32:30 +02:00
parent b32b60e3fa
commit 54cf7557e5
3 changed files with 21 additions and 17 deletions

View File

@ -5,14 +5,18 @@ define(function(require) {
appController = require('js/app-controller'); appController = require('js/app-controller');
var LoginExistingCtrl = function($scope, $location) { var LoginExistingCtrl = function($scope, $location) {
$scope.incorrect = false;
$scope.confirmPassphrase = function() { $scope.confirmPassphrase = function() {
var passphrase = $scope.passphrase, var passphrase = $scope.passphrase,
emailDao = appController._emailDao; emailDao = appController._emailDao;
if (!passphrase) { if (!passphrase) {
$scope.incorrect = true;
return; return;
} }
$scope.incorrect = false;
unlockCrypto(imapLogin); unlockCrypto(imapLogin);
function unlockCrypto(callback) { function unlockCrypto(callback) {
@ -30,6 +34,8 @@ define(function(require) {
}; };
emailDao.unlock(keypair, passphrase, function(err) { emailDao.unlock(keypair, passphrase, function(err) {
if (err) { if (err) {
$scope.incorrect = true;
$scope.$apply();
callback(err); callback(err);
return; return;
} }
@ -73,8 +79,7 @@ define(function(require) {
return; return;
} }
reader.onload = (function(scope) { reader.onload = function(e) {
return function(e) {
var rawKeys = e.target.result, var rawKeys = e.target.result,
index = rawKeys.indexOf('-----BEGIN PGP PRIVATE KEY BLOCK-----'); index = rawKeys.indexOf('-----BEGIN PGP PRIVATE KEY BLOCK-----');
@ -84,11 +89,11 @@ define(function(require) {
} }
scope.key = { scope.key = {
publicKeyArmored: rawKeys.substring(0,index), publicKeyArmored: rawKeys.substring(0, index),
privateKeyArmored: rawKeys.substring(index,rawKeys.length) privateKeyArmored: rawKeys.substring(index, rawKeys.length)
}; };
scope.$apply();
}; };
})(scope);
reader.readAsText(files[0]); reader.readAsText(files[0]);
}); });
}; };

View File

@ -7,7 +7,6 @@
<div class="content"> <div class="content">
<h1>Set passphrase</h1> <h1>Set passphrase</h1>
<p>The passphrase protects your private key.</p>
<p>If you forget your passphrase, there is no way to restore your data. So it might be a good idea to write it down and keep it in a safe place.</p> <p>If you forget your passphrase, there is no way to restore your data. So it might be a good idea to write it down and keep it in a safe place.</p>
<form> <form>

View File

@ -7,11 +7,11 @@
<div class="content"> <div class="content">
<h1>Import keyfile</h1> <h1>Import keyfile</h1>
<p>You are already registered on another device. To access your communication on this device, please import the encrypted key file.</p> <p>You are already registered on another device. To access your emails on this device, please import your key file.</p>
<form> <form>
<div><input type="file" file-reader tabindex="1"></div> <div><input type="file" file-reader tabindex="1"></div>
<div><input type="password" ng-model="passphrase" placeholder="Passphrase" tabindex="2"></div> <div><input type="password" ng-model="passphrase" ng-class="{error:incorrect}" placeholder="Passphrase" tabindex="2"></div>
<div><button type="submit" ng-click="confirmPassphrase()" class="btn" ng-disabled="!key" tabindex="3">Import</button> <div><button type="submit" ng-click="confirmPassphrase()" class="btn" ng-disabled="!key" tabindex="3">Import</button>
</form> </form>
</div> </div>