-
-
Save gr2m/5463426 to your computer and use it in GitHub Desktop.
// sign up | |
account.signUp('[email protected]', 'secret'); | |
// sign in | |
account.signIn('[email protected]', 'secret'); | |
// sign in via oauth | |
account.signInWith('twitter'); | |
// sign out | |
account.signOut(); | |
// change password | |
account.changePassword('currentpassword', 'newpassword'); | |
// change username | |
account.changeUsername('currentpassword', 'newusername'); | |
// reset password | |
account.resetPassword('[email protected]'); | |
// destroy account and all its data | |
account.destroy('currentpassword'); | |
// all methods could alternatively accept a parameter hash | |
// that would also allow for additional user info | |
account.signUp({ | |
username: 'joe2000', | |
password: 'secret', | |
birthday: '1984-05-09', | |
email: '[email protected]' | |
}); | |
// that would also allow for a general change method, | |
// that changeUsername or changePassword would simply | |
// be shortcuts for | |
account.change({ | |
birthday: '1984-05-09', | |
}); | |
account.change({ | |
username: 'joe3000', | |
password: 'secret' | |
}); |
Hi!
I've created the signUp(email, password)
function using Firebase.
You can see it in action here (and edit the code obviously): http://codepen.io/rezozo/pen/jEbQEL
-- Jonathan
How to add capcha support?
WOW! This is amazing!
var u = new User(); // the User Class (ValueObject) can be reused for anything else
u.username ="joe2000";
u.password = "secret";
u.birthday = "1984-05-09";
u.email = "[email protected]"
Users.signUp(u);
And this all with full IntelliSense:
you just have to type u.
then hit ctrl+space
and the IDE shows you all possible values and you just have to choose them!
That way you can create your Objects and leave them alone.
You no longer have to remember any variable.
instead of a JSON Object where yopu have to remember or lookup possible object variables:
account.signUp({
username: 'joe2000',
password: 'secret',
birthday: '1984-05-09',
email: '[email protected]'
});
something like u = User().email('[email protected]').password('').sudo() could give me a window.user and if pass is wrong, just send an email that allows to sign in once, or change password + autosignin in the other window. Omittting .password() would make the signin code attempt to use whatever browser or other APIs available and fallback to the email-as-login approach. If browser has multiple possibilities like Persona, Oauths, SQRL, then a stored cookie is used to record stats on how succesful the approaches have been, to avoid begging for Facebook Oauth from someone who never used it before, but show it immediately to one who exclusively prefers it.
https://medium.com/@ninjudd/passwords-are-obsolete-9ed56d483eb