Skip to content

Instantly share code, notes, and snippets.

@joegaudet
Forked from jberthet/autofill_login.js
Last active December 11, 2015 22:18
Show Gist options
  • Save joegaudet/4668064 to your computer and use it in GitHub Desktop.
Save joegaudet/4668064 to your computer and use it in GitHub Desktop.
MyApp.MainPage.MainPain: SC.MainPane.create({
didCreateLayer: function(){
SC.Event.add($('#login-name')[0], 'change', this, this.userNameDidChange);
SC.Event.add($('#login-passwd')[0], 'change', this, this.passwordDidChange);
},
userNameDidChange: function(){
AuthAo.loginController.set('username', $('#login-name').val());
},
passwordDidChange: function(){
AuthAo.loginController.set('password', $('#login-passwd').val());
}
})
AuthAo.loginController = SC.Controller.create({
setFieldsWithBrowserDefault: function() {
}
});
MyApp.LOGGED_OUT = SC.State.extend
({
didCompleteCredentialCheck: function(response) {
var resp_body = response.get('body');
var lc = AuthAo.loginController;
if (SC.ok(response)) {
/* Login OK, do some stuff here */
}
else {
lc.setFieldsWithBrowserDefault();
var loginPane = MyApp.getPath('loginPane');
loginPane.append();
loginPane.focus();
}
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment