[WO-297] setting a passphrase is optional

This commit is contained in:
Tankred Hase 2014-03-28 17:40:02 +01:00
parent b7e0236af8
commit 1c877634d1
5 changed files with 33 additions and 21 deletions

View File

@ -15,6 +15,23 @@ define(function(require) {
$scope.buttonEnabled = true;
$scope.incorrect = false;
//
// Try unlocking without passphrase
//
unlockCrypto(function(err) {
if (err) {
return;
}
$location.path('/desktop');
$scope.$apply();
});
//
// Unlock using passphrase
//
$scope.change = function() {
$scope.incorrect = false;
};
@ -27,10 +44,10 @@ define(function(require) {
// disable button once loggin has started
$scope.buttonEnabled = false;
$scope.incorrect = false;
unlockCrypto();
unlockCrypto(onUnlock);
};
function unlockCrypto() {
function unlockCrypto(callback) {
var userId = emailDao._account.emailAddress;
appController._emailDao._keychain.getUserKeyPair(userId, function(err, keypair) {
if (err) {
@ -41,7 +58,7 @@ define(function(require) {
emailDao.unlock({
keypair: keypair,
passphrase: $scope.passphrase
}, onUnlock);
}, callback);
});
}

View File

@ -53,12 +53,13 @@ define(function(require) {
return str.substring(0, 1).toLowerCase() + str.substring(1);
}
if (!passphrase || passphrase.length < 10) {
$scope.passphraseMsg = 'Too short';
if (!passphrase) {
// no rating for empty passphrase
$scope.passphraseMsg = '';
return;
}
if (SAME.test(passphrase)) {
if (passphrase.length < 8 || SAME.test(passphrase)) {
$scope.passphraseMsg = 'Very weak';
return;
}
@ -85,14 +86,14 @@ define(function(require) {
var passphrase = $scope.state.passphrase,
confirmation = $scope.state.confirmation;
if (!passphrase || passphrase !== confirmation) {
if (passphrase !== confirmation) {
return;
}
$scope.setState(states.PROCESSING);
setTimeout(function() {
emailDao.unlock({
passphrase: passphrase
passphrase: (passphrase) ? passphrase : undefined
}, function(err) {
if (err) {
$scope.setState(states.IDLE);

View File

@ -17,11 +17,6 @@ define(function(require) {
$scope.incorrect = false;
$scope.confirmPassphrase = function() {
if (!$scope.passphrase) {
$scope.incorrect = true;
return;
}
$scope.incorrect = false;
unlockCrypto();
};

View File

@ -119,7 +119,7 @@ define(function(require) {
var pubKeyId, privKeyId, self = this;
// check options
if (typeof options.passphrase !== 'string' || !options.privateKeyArmored || !options.publicKeyArmored) {
if (!options.privateKeyArmored || !options.publicKeyArmored) {
callback({
errMsg: 'Importing keys failed. Not all options set!'
});

View File

@ -6,22 +6,22 @@
<div class="content" ng-switch on="state.ui">
<div ng-switch-when="1">
<p><b>Generate PGP key.</b> Choose a passphrase to protect your new key. If you forget it at a later time you will not be able to read past messages.</p><p>Alternatively you can also <a href="#" ng-click="$event.preventDefault(); importKey()">import an existing PGP key</a>.</p>
<p><b>Generate PGP key.</b> You can set a passphrase to protect your key on disk. But you will have to enter it everytime you open the app. If not just press continue.</p><p>Alternatively you can also <a href="#" ng-click="$event.preventDefault(); importKey()">import an existing PGP key</a>.</p>
<form>
<div>
<label class="input-error-message" ng-class="{'passphrase-label-ok': passphraseRating >= 2}">{{passphraseMsg}}</label><br>
<input class="input-text" ng-class="{'input-text-error': passphraseRating < 2}" type="password" ng-model="state.passphrase" ng-change="checkPassphraseQuality()" placeholder="Enter passphrase" tabindex="1" focus-me="true">
<input class="input-text" type="password" ng-model="state.confirmation" ng-class="{'input-text-error': state.confirmation && state.confirmation !== state.passphrase}" placeholder="Confirm passphrase" tabindex="2">
<input class="input-text" type="password" ng-model="state.passphrase" ng-change="checkPassphraseQuality()" placeholder="Enter passphrase" tabindex="1" focus-me="true">
<input class="input-text" type="password" ng-model="state.confirmation" ng-class="{'input-text-error': (state.confirmation || state.passphrase) && state.confirmation !== state.passphrase}" placeholder="Confirm passphrase" tabindex="2">
<span class="popover-info" data-icon-append="&#xe010;" popover="#passphrase-info"></span>
</div>
<div>
<button type="submit" ng-click="confirmPassphrase()" class="btn" ng-disabled="!state.passphrase || passphraseRating < 2 || state.passphrase !== state.confirmation" tabindex="3">Generate keypair</button>
<button type="submit" ng-click="confirmPassphrase()" class="btn" ng-disabled="(state.confirmation || state.passphrase) && state.confirmation !== state.passphrase" tabindex="3">Continue</button>
</div>
</form>
</div>
<div ng-switch-when="2">
<p><b>Generating keypair.</b> Please stand by. This can take a while...</p>
<p><b>Generating key.</b> Please stand by. This can take a while...</p>
</div>
<div ng-switch-when="4">
@ -43,9 +43,8 @@
<div class="arrow"></div>
<div class="popover-title"><b>What is this?</b></div>
<div class="popover-content">
<p>A passphrase is like a password but longer.</p>
<p>A passphrase is like a password that protects your PGP key.</p>
<p>If your device is lost or stolen the passphrase protects the contents of your mailbox.</p>
<p>It must be at least 10 characters long and contain one special character or digit.</p>
<p>You cannot change your passphrase at a later time.</p>
</div>
</div><!--/.popover-->