mirror of
https://github.com/moparisthebest/mail
synced 2025-02-16 07:00:09 -05:00
Fix redirect bug in login ctrl
This commit is contained in:
parent
6beddf4760
commit
383761e6cb
@ -32,19 +32,23 @@ var LoginCtrl = function($scope, $timeout, $location, updateHandler, account, au
|
||||
function redirect(availableKeys) {
|
||||
if (availableKeys && availableKeys.publicKey && availableKeys.privateKey) {
|
||||
// public and private key available, try empty passphrase
|
||||
var passphraseIncorrect;
|
||||
return email.unlock({
|
||||
keypair: availableKeys,
|
||||
passphrase: undefined
|
||||
}).catch(function() {
|
||||
passphraseIncorrect = true;
|
||||
// passphrase set... ask for passphrase
|
||||
return $scope.goTo('/login-existing');
|
||||
|
||||
}).then(function() {
|
||||
if (passphraseIncorrect) {
|
||||
return;
|
||||
}
|
||||
// no passphrase set... go to main screen
|
||||
return auth.storeCredentials();
|
||||
|
||||
}).then(function() {
|
||||
return $scope.goTo('/account');
|
||||
return auth.storeCredentials().then(function() {
|
||||
return $scope.goTo('/account');
|
||||
});
|
||||
});
|
||||
|
||||
} else if (availableKeys && availableKeys.publicKey && !availableKeys.privateKey) {
|
||||
|
@ -86,7 +86,8 @@ describe('Login Controller unit test', function() {
|
||||
authMock.getEmailAddress.returns(resolves({}));
|
||||
|
||||
scope.init().then(function() {
|
||||
expect(goToStub.withArgs('/add-account').calledOnce).to.be.true;
|
||||
expect(goToStub.withArgs('/add-account').called).to.be.true;
|
||||
expect(goToStub.calledOnce).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -103,7 +104,9 @@ describe('Login Controller unit test', function() {
|
||||
emailMock.unlock.returns(rejects(new Error()));
|
||||
|
||||
scope.init().then(function() {
|
||||
expect(goToStub.withArgs('/login-existing').calledOnce).to.be.true;
|
||||
expect(goToStub.withArgs('/login-existing').called).to.be.true;
|
||||
expect(goToStub.calledOnce).to.be.true;
|
||||
expect(authMock.storeCredentials.called).to.be.false;
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -139,7 +142,8 @@ describe('Login Controller unit test', function() {
|
||||
authMock.storeCredentials.returns(resolves());
|
||||
|
||||
scope.init().then(function() {
|
||||
expect(goToStub.withArgs('/account').calledOnce).to.be.true;
|
||||
expect(goToStub.withArgs('/account').called).to.be.true;
|
||||
expect(goToStub.calledOnce).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -171,7 +175,8 @@ describe('Login Controller unit test', function() {
|
||||
keychainMock.requestPrivateKeyDownload.returns(resolves(true));
|
||||
|
||||
scope.init().then(function() {
|
||||
expect(goToStub.withArgs('/login-privatekey-download').calledOnce).to.be.true;
|
||||
expect(goToStub.withArgs('/login-privatekey-download').called).to.be.true;
|
||||
expect(goToStub.calledOnce).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -187,7 +192,8 @@ describe('Login Controller unit test', function() {
|
||||
keychainMock.requestPrivateKeyDownload.returns(resolves());
|
||||
|
||||
scope.init().then(function() {
|
||||
expect(goToStub.withArgs('/login-new-device').calledOnce).to.be.true;
|
||||
expect(goToStub.withArgs('/login-new-device').called).to.be.true;
|
||||
expect(goToStub.calledOnce).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -200,7 +206,8 @@ describe('Login Controller unit test', function() {
|
||||
accountMock.init.returns(resolves({}));
|
||||
|
||||
scope.init().then(function() {
|
||||
expect(goToStub.withArgs('/login-initial').calledOnce).to.be.true;
|
||||
expect(goToStub.withArgs('/login-initial').called).to.be.true;
|
||||
expect(goToStub.calledOnce).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user