1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 10:52:17 -05:00

[WO-111] add error hadnling to login.js

This commit is contained in:
Tankred Hase 2013-11-12 20:00:53 +01:00
parent 6ea815221c
commit 8ac1882280
3 changed files with 27 additions and 9 deletions

View File

@ -70,9 +70,10 @@ define(function(require) {
'interactive': true
},
function(token) {
if (!token) {
if ((chrome && chrome.runtime && chrome.runtime.lastError) || !token) {
callback({
errMsg: 'Error fetching an OAuth token for the user!'
errMsg: 'Error fetching an OAuth token for the user!',
err: chrome.runtime.lastError
});
return;
}

View File

@ -4,9 +4,21 @@ define(function(require) {
var appController = require('js/app-controller');
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) {
if (err) {
console.error(err);
$scope.onError(err);
return;
}
@ -27,22 +39,22 @@ define(function(require) {
// get OAuth token from chrome
appController.fetchOAuthToken(function(err, auth) {
if (err) {
console.error(err);
$scope.onError(err);
return;
}
// initiate controller by creating email dao
appController.init(auth.emailAddress, auth.token, function(err, availableKeys) {
if (err) {
console.error(err);
$scope.onError(err);
return;
}
// login to imap backend
appController._emailDao.imapLogin(function(err) {
if (err) {
console.error(err);
console.log('Error logging into IMAP... proceeding in offline mode.');
$scope.onError(err);
return;
}
redirect(availableKeys);

View File

@ -6,8 +6,13 @@
<div class="content">
<h1>Login</h1>
<p>Authenticating with the mail server...</p>
</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-->