},
loginFailed: function(inSender, inEvent) {
alert('Login failed');
+ this.waterfall('onShowForgotPasswordLink');
this.logout();
},
logout: function(inSender, inEvent) {
handlers: {
onLogin: "login",
onLogout: "logout",
- onPostVisibility: "postVisibilityUpdate"
+ onPostVisibility: "postVisibilityUpdate",
+ onShowForgotPasswordLink: "showForgotPasswordLink"
},
components: [
{name: "loggedOutControls", components: [
{name: "password", kind: "onyx.Input", placeholder: "Password", type: "password", attributes: {tabindex: 2}}
]},
]},
- {kind: "onyx.Button", content: "Login", onclick: "loginClicked", attributes: {tabindex: 3}}
+ {kind: "onyx.Button", content: "Login", onclick: "loginClicked", attributes: {tabindex: 3}},
+ {name: "forgotPassword", showing: false, style: "margin-top: 10px; text-align: left", components: [
+ {kind: "blerg.Link", content: "Forgot your password?", onNavigate: "popupForgotPasswordDialog"}
+ ]}
]}
]},
{name: "loggedInControls", showing: false, components: [
{name: "spewButton", kind: "onyx.Button", classes: "spew-button", content: "Spew It!", onclick: "spewToggle"}
]},
]},
+ {name: "forgotPasswordDialog", kind: "blerg.ForgotPasswordDialog"},
{name: "api", kind: "blerg.API",
onStatus: "gotStatus"},
{kind: "Signals",
},
login: function(inSender, inEvent) {
this.$.password.setValue('');
+ this.$.forgotPassword.hide();
// TODO: Replace with regular blur() call in future enyo
this.$.password.node.blur();
this.setLoggedIn(true);
} else if (inEvent.type == 'mentioned') {
this.gotStatus(this, {mentioned: false});
}
+ },
+ showForgotPasswordLink: function(inSender, inevent) {
+ this.$.forgotPassword.show();
+ },
+ popupForgotPasswordDialog: function() {
+ this.$.forgotPasswordDialog.setUsername(this.$.username.getValue());
+ this.$.forgotPasswordDialog.show();
}
});
+enyo.kind({
+ name: "blerg.ForgotPasswordDialog",
+ kind: "onyx.Popup",
+ classes: "blerg-dialog",
+ autoDismiss: true,
+ centered: true,
+ floating: true,
+ modal: true,
+ components: [
+ {tag: "h2", content: "Forgot Password"},
+ {name: "spinner", kind: "OldSchoolSpinner", showing: false, style: "position: absolute; top: 8px; right: 8px;"},
+ {kind: "onyx.Groupbox", components: [
+ {kind: "onyx.InputDecorator", components: [
+ {name: "username", kind: "onyx.Input", placeholder: "Username"}
+ ]},
+ {kind: "onyx.InputDecorator", components: [
+ {name: "email", kind: "onyx.Input", placeholder: "Email Address"}
+ ]}
+ ]},
+ {name: "recoverError", tag: "p", showing: false, classes: 'blerg-error', content: "Please enter both username and email."},
+ {name: "recoverButton", kind: "onyx.Button", content: "Send Recovery Email", onclick: "recoverClick", classes: "onyx-affirmative"},
+ {kind: "onyx.Button", content: "Cancel", onclick: "cancelClick", classes: "onyx-negative"}
+ ],
+ recoverClick: function() {
+ var username = this.$.username.getValue();
+ var email = this.$.email.getValue();
+
+ if (!(username != '' && email != '')) {
+ this.$.recoverError.show();
+ return;
+ }
+
+ this.$.recoverButton.setDisabled(true);
+ this.$.spinner.show();
+ this.$.spinner.start();
+
+ var req = new enyo.Ajax({
+ url: '/aux/recovery/mail',
+ method: 'POST',
+ postBody: {
+ username: username,
+ email: email
+ }
+ });
+
+ req.response(this, function(inSender, inResponse) {
+ this.$.spinner.stop();
+ this.$.spinner.hide();
+ this.$.recoverButton.setDisabled(false);
+
+ if (inResponse.status == 'success') {
+ alert("Recovery email sent");
+ this.cancelClick();
+ }
+ });
+
+ req.error(this, function(inSender, inResponse) {
+ this.$.spinner.stop();
+ this.$.spinner.hide();
+ this.$.recoverButton.setDisabled(false);
+
+ alert("Failed due to backend error");
+ });
+
+ req.go();
+ },
+ cancelClick: function() {
+ this.$.username.setValue('');
+ this.$.email.setValue('');
+ this.hide();
+ },
+ setUsername: function(v) {
+ this.$.username.setValue(v);
+ }
+});
'Help.js',
'Main.js',
'SignupDialog.js',
+ 'ForgotPasswordDialog.js',
'PasswdForm.js',
'EmailForm.js',
'EmailVerify.js',