1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-29 20:32: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');
var LoginExistingCtrl = function($scope, $location) {
$scope.incorrect = false;
$scope.confirmPassphrase = function() {
var passphrase = $scope.passphrase,
emailDao = appController._emailDao;
if (!passphrase) {
$scope.incorrect = true;
return;
}
$scope.incorrect = false;
unlockCrypto(imapLogin);
function unlockCrypto(callback) {
@ -30,6 +34,8 @@ define(function(require) {
};
emailDao.unlock(keypair, passphrase, function(err) {
if (err) {
$scope.incorrect = true;
$scope.$apply();
callback(err);
return;
}
@ -73,8 +79,7 @@ define(function(require) {
return;
}
reader.onload = (function(scope) {
return function(e) {
reader.onload = function(e) {
var rawKeys = e.target.result,
index = rawKeys.indexOf('-----BEGIN PGP PRIVATE KEY BLOCK-----');
@ -84,11 +89,11 @@ define(function(require) {
}
scope.key = {
publicKeyArmored: rawKeys.substring(0,index),
privateKeyArmored: rawKeys.substring(index,rawKeys.length)
publicKeyArmored: rawKeys.substring(0, index),
privateKeyArmored: rawKeys.substring(index, rawKeys.length)
};
scope.$apply();
};
})(scope);
reader.readAsText(files[0]);
});
};

View File

@ -7,7 +7,6 @@
<div class="content">
<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>
<form>

View File

@ -7,11 +7,11 @@
<div class="content">
<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>
<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>
</form>
</div>