Merge remote-tracking branch 'origin/dev/login-error'

This commit is contained in:
Felix Hammerl 2013-11-13 18:59:25 +01:00
commit abe4380a24
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-->