1
0
mirror of https://github.com/moparisthebest/mail synced 2024-08-13 16:43:47 -04: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,22 +79,21 @@ define(function(require) {
return;
}
reader.onload = (function(scope) {
return function(e) {
var rawKeys = e.target.result,
index = rawKeys.indexOf('-----BEGIN PGP PRIVATE KEY BLOCK-----');
if (index === -1) {
console.error('Erroneous key file format!');
return;
}
reader.onload = function(e) {
var rawKeys = e.target.result,
index = rawKeys.indexOf('-----BEGIN PGP PRIVATE KEY BLOCK-----');
scope.key = {
publicKeyArmored: rawKeys.substring(0,index),
privateKeyArmored: rawKeys.substring(index,rawKeys.length)
};
if (index === -1) {
console.error('Erroneous key file format!');
return;
}
scope.key = {
publicKeyArmored: rawKeys.substring(0, index),
privateKeyArmored: rawKeys.substring(index, rawKeys.length)
};
})(scope);
scope.$apply();
};
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>