Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
68
gaia/apps/email/js/cards/setup_fix_oauth2.js
Executable file
68
gaia/apps/email/js/cards/setup_fix_oauth2.js
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
'use strict';
|
||||
define(function(require) {
|
||||
|
||||
var oauthFetch = require('./oauth2/fetch'),
|
||||
cards = require('cards');
|
||||
|
||||
return [
|
||||
require('./base_card')(require('template!./setup_fix_oauth2.html')),
|
||||
{
|
||||
extraClasses: ['anim-fade', 'anim-overlay'],
|
||||
|
||||
onArgs: function(args) {
|
||||
this.account = args.account;
|
||||
this.restoreCard = args.restoreCard;
|
||||
|
||||
// The account name is not translatable; set it verbatim.
|
||||
this.oauth2Name.textContent = this.account.name;
|
||||
},
|
||||
|
||||
die: function() {
|
||||
// no special cleanup required
|
||||
},
|
||||
|
||||
onReauth: function(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
var oauth2 = this.account._wireRep.credentials.oauth2;
|
||||
oauthFetch(oauth2, {
|
||||
login_hint: this.account.username
|
||||
})
|
||||
.then(function(response) {
|
||||
// Cancellation means hide this UI.
|
||||
if (response.status === 'cancel') {
|
||||
this.delayedClose();
|
||||
// Success means victory.
|
||||
} else if (response.status === 'success') {
|
||||
this.account.modifyAccount({ oauthTokens: response.tokens });
|
||||
this.account.clearProblems();
|
||||
this.delayedClose();
|
||||
|
||||
// Anything else means a failure and it's also time to close.
|
||||
} else {
|
||||
console.error('Unknown oauthFetch status: ' + response.status);
|
||||
this.delayedClose();
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
delayedClose: function() {
|
||||
// The setTimeout is a hack. See the comment in setup_progress, in
|
||||
// onCardVisible, similar issue here, but for the close of the oauth
|
||||
// card.
|
||||
setTimeout(this.close.bind(this), 100);
|
||||
},
|
||||
|
||||
close: function(event) {
|
||||
if (event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
cards.removeCardAndSuccessors(this, 'animate', 1,
|
||||
this.restoreCard);
|
||||
}
|
||||
}
|
||||
];
|
||||
});
|
||||
Loading…
Reference in a new issue