mirror of
https://github.com/moparisthebest/mail
synced 2025-02-16 23:20:09 -05:00
Login to IMAP (appcontroller.onConnect) after show mail-list
This commit is contained in:
parent
1c877634d1
commit
4b5d367fdb
@ -127,11 +127,6 @@ define(function(require) {
|
||||
console.log('IMAP reconnecting...');
|
||||
// re-init client modules on error
|
||||
self.onConnect(function(err) {
|
||||
if (!self._initialized) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
console.error('IMAP reconnect failed!', err);
|
||||
return;
|
||||
@ -398,15 +393,7 @@ define(function(require) {
|
||||
return;
|
||||
}
|
||||
|
||||
// connect tcp clients on first startup
|
||||
self.onConnect(function(err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null, keypair);
|
||||
});
|
||||
callback(null, keypair);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -15,23 +15,6 @@ 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;
|
||||
};
|
||||
@ -44,10 +27,10 @@ define(function(require) {
|
||||
// disable button once loggin has started
|
||||
$scope.buttonEnabled = false;
|
||||
$scope.incorrect = false;
|
||||
unlockCrypto(onUnlock);
|
||||
unlockCrypto();
|
||||
};
|
||||
|
||||
function unlockCrypto(callback) {
|
||||
function unlockCrypto() {
|
||||
var userId = emailDao._account.emailAddress;
|
||||
appController._emailDao._keychain.getUserKeyPair(userId, function(err, keypair) {
|
||||
if (err) {
|
||||
@ -58,7 +41,7 @@ define(function(require) {
|
||||
emailDao.unlock({
|
||||
keypair: keypair,
|
||||
passphrase: $scope.passphrase
|
||||
}, callback);
|
||||
}, onUnlock);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ define(function(require) {
|
||||
|
||||
// check if account needs to be selected
|
||||
if (!emailAddress) {
|
||||
firstLogin();
|
||||
goTo('/add-account');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -53,23 +53,32 @@ define(function(require) {
|
||||
});
|
||||
}
|
||||
|
||||
function firstLogin() {
|
||||
$location.path('/add-account');
|
||||
$scope.$apply();
|
||||
}
|
||||
|
||||
function redirect(availableKeys) {
|
||||
// redirect if needed
|
||||
if (typeof availableKeys === 'undefined') {
|
||||
// no public key available, start onboarding process
|
||||
$location.path('/login-initial');
|
||||
goTo('/login-initial');
|
||||
} else if (!availableKeys.privateKey) {
|
||||
// no private key, import key
|
||||
$location.path('/login-new-device');
|
||||
goTo('/login-new-device');
|
||||
} else {
|
||||
// public and private key available, just login
|
||||
$location.path('/login-existing');
|
||||
// public and private key available, try empty passphrase
|
||||
appController._emailDao.unlock({
|
||||
keypair: availableKeys,
|
||||
passphrase: undefined
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
goTo('/login-existing');
|
||||
return;
|
||||
}
|
||||
|
||||
goTo('/desktop');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function goTo(location) {
|
||||
$location.path(location);
|
||||
$scope.$apply();
|
||||
}
|
||||
};
|
||||
|
@ -19,9 +19,6 @@ define(function(require) {
|
||||
// attach global error handler
|
||||
errorUtil.attachHandler($scope);
|
||||
|
||||
// app controller is initialized
|
||||
appController._initialized = true;
|
||||
|
||||
emailDao = appController._emailDao;
|
||||
outboxBo = appController._outboxBo;
|
||||
|
||||
@ -70,6 +67,8 @@ define(function(require) {
|
||||
initFolders();
|
||||
// select inbox as the current folder on init
|
||||
$scope.openFolder($scope.account.folders[0]);
|
||||
// connect imap/smtp clients on first startup
|
||||
appController.onConnect($scope.onError);
|
||||
|
||||
//
|
||||
// helper functions
|
||||
|
@ -19,7 +19,7 @@ define(function(require) {
|
||||
PGP.prototype.generateKeys = function(options, callback) {
|
||||
var userId;
|
||||
|
||||
if (!util.emailRegEx.test(options.emailAddress) || !options.keySize || typeof options.passphrase !== 'string') {
|
||||
if (!util.emailRegEx.test(options.emailAddress) || !options.keySize) {
|
||||
callback({
|
||||
errMsg: 'Crypto init failed. Not all options set!'
|
||||
});
|
||||
|
@ -73,7 +73,24 @@ define(function(require) {
|
||||
return;
|
||||
}
|
||||
|
||||
self._account.folders = folders;
|
||||
// if empty (first time login) use dummy folders ... overwritten in onConnect
|
||||
self._account.folders = (folders) ? folders : [{
|
||||
type: 'Inbox',
|
||||
path: 'INBOX'
|
||||
}, {
|
||||
type: 'Sent',
|
||||
path: 'SENT'
|
||||
}, {
|
||||
type: 'Outbox',
|
||||
path: 'OUTBOX'
|
||||
}, {
|
||||
type: 'Drafts',
|
||||
path: 'DRAFTS'
|
||||
}, {
|
||||
type: 'Trash',
|
||||
path: 'TRASH'
|
||||
}];
|
||||
|
||||
callback(null, keypair);
|
||||
});
|
||||
}
|
||||
@ -114,13 +131,6 @@ define(function(require) {
|
||||
// set status to online
|
||||
self._account.online = true;
|
||||
|
||||
// check memory
|
||||
if (self._account.folders) {
|
||||
// no need to init folder again on connect... already in memory
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
// init folders
|
||||
self._imapListFolders(function(err, folders) {
|
||||
if (err) {
|
||||
|
Loading…
Reference in New Issue
Block a user