mirror of https://github.com/moparisthebest/mail
Merge remote-tracking branch 'origin/dev/login-error'
This commit is contained in:
commit
abe4380a24
|
@ -70,9 +70,10 @@ define(function(require) {
|
||||||
'interactive': true
|
'interactive': true
|
||||||
},
|
},
|
||||||
function(token) {
|
function(token) {
|
||||||
if (!token) {
|
if ((chrome && chrome.runtime && chrome.runtime.lastError) || !token) {
|
||||||
callback({
|
callback({
|
||||||
errMsg: 'Error fetching an OAuth token for the user!'
|
errMsg: 'Error fetching an OAuth token for the user!',
|
||||||
|
err: chrome.runtime.lastError
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,21 @@ define(function(require) {
|
||||||
var appController = require('js/app-controller');
|
var appController = require('js/app-controller');
|
||||||
|
|
||||||
var LoginCtrl = function($scope, $location) {
|
var LoginCtrl = function($scope, $location) {
|
||||||
|
// global state... inherited to all child scopes
|
||||||
|
$scope.$root.state = {};
|
||||||
|
|
||||||
|
$scope.$root.onError = function(options) {
|
||||||
|
console.error(options);
|
||||||
|
$scope.state.dialog = {
|
||||||
|
open: true,
|
||||||
|
title: options.title || 'Error',
|
||||||
|
message: options.message || options.errMsg
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
appController.start(function(err) {
|
appController.start(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
$scope.onError(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,22 +39,22 @@ define(function(require) {
|
||||||
// get OAuth token from chrome
|
// get OAuth token from chrome
|
||||||
appController.fetchOAuthToken(function(err, auth) {
|
appController.fetchOAuthToken(function(err, auth) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
$scope.onError(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initiate controller by creating email dao
|
// initiate controller by creating email dao
|
||||||
appController.init(auth.emailAddress, auth.token, function(err, availableKeys) {
|
appController.init(auth.emailAddress, auth.token, function(err, availableKeys) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
$scope.onError(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// login to imap backend
|
// login to imap backend
|
||||||
appController._emailDao.imapLogin(function(err) {
|
appController._emailDao.imapLogin(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
$scope.onError(err);
|
||||||
console.log('Error logging into IMAP... proceeding in offline mode.');
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(availableKeys);
|
redirect(availableKeys);
|
||||||
|
|
|
@ -6,8 +6,13 @@
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>Login</h1>
|
<h1>Login</h1>
|
||||||
|
|
||||||
<p>Authenticating with the mail server...</p>
|
<p>Authenticating with the mail server...</p>
|
||||||
</div><!--/content-->
|
</div><!--/content-->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- lightbox -->
|
||||||
|
<div class="lightbox-overlay" ng-class="{'show': state.dialog.open}">
|
||||||
|
<div class="lightbox lightbox-effect view-dialog" ng-include="'tpl/dialog.html'"></div>
|
||||||
|
</div>
|
||||||
|
<!--/.lightbox-overlay-->
|
Loading…
Reference in New Issue