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
74
gaia/apps/email/js/cards/settings_account_credentials.js
Executable file
74
gaia/apps/email/js/cards/settings_account_credentials.js
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
'use strict';
|
||||
define(function(require) {
|
||||
|
||||
var mozL10n = require('l10n!'),
|
||||
cards = require('cards'),
|
||||
oauthFetch = require('./oauth2/fetch');
|
||||
|
||||
return [
|
||||
require('./base_card')
|
||||
(require('template!./settings_account_credentials.html')),
|
||||
{
|
||||
onArgs: function(args) {
|
||||
this.account = args.account;
|
||||
this.headerLabel.textContent = this.account.name;
|
||||
|
||||
// If we're not using password auth, then hide the password box and the
|
||||
// save UI for it.
|
||||
if (this.account.authMechanism !== 'password') {
|
||||
this.querySelector('.tng-account-server-password')
|
||||
.classList.add('collapsed');
|
||||
this.saveButton.classList.add('collapsed');
|
||||
}
|
||||
|
||||
// If the account is explicitly an oauth2 type, then show the reauthorize
|
||||
// button.
|
||||
if (this.account.authMechanism === 'oauth2') {
|
||||
this.reauthButton.classList.remove('collapsed');
|
||||
}
|
||||
|
||||
this.usernameNodeInput.value = this.account.username;
|
||||
},
|
||||
|
||||
onBack: function() {
|
||||
cards.removeCardAndSuccessors(this, 'animate', 1);
|
||||
},
|
||||
|
||||
onClickSave: function() {
|
||||
var password = this.passwordNodeInput.value;
|
||||
|
||||
if (password) {
|
||||
this.account.modifyAccount({password: password});
|
||||
this.account.clearProblems();
|
||||
} else {
|
||||
alert(mozL10n.get('settings-password-empty'));
|
||||
}
|
||||
|
||||
this.onBack();
|
||||
},
|
||||
|
||||
onClickReauth: function() {
|
||||
var oauth2 = this.account._wireRep.credentials.oauth2;
|
||||
oauthFetch(oauth2, {
|
||||
login_hint: this.account.username
|
||||
})
|
||||
.then(function(response) {
|
||||
if (response.status === 'success') {
|
||||
this.account.modifyAccount({ oauthTokens: response.tokens });
|
||||
|
||||
// The user may have reauthed because they canceled an onbadlogin
|
||||
// card but came here to try to fix the problem, so ask to clear
|
||||
// problems if possible.
|
||||
this.account.clearProblems();
|
||||
|
||||
// Successfully reauthed, nothing else to do on this card.
|
||||
this.onBack();
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
die: function() {
|
||||
}
|
||||
}
|
||||
];
|
||||
});
|
||||
Loading…
Reference in a new issue