// this is derived from
// http://stackoverflow.com/questions/15167981/how-do-i-use-firebase-simple-login-with-email-password/15167983#15167983
// CHANGE THIS to your own firebase
var ref = new Firebase("https://xxx.firebaseio.com");
// then go to your firebase console, click the auth tab, scroll down to
// authentication providers, and enable 'email/password'
// Now enter this in the 'Auth' tab to the left.
/*
{
"rules": {
"users": {
"$userid": {
".read": "auth.id == $userid",
".write": "auth.id == $userid"
}
}
}
}
*/
//
// global user (is this a good thing?)
myUser = -1;
$(function () {
$("#dialog-register").dialog({
autoOpen: false,
buttons: {
"ok": function () {
var email = $("#register-email").val();
var password = $("#register-password").val();
authClient.createUser(email, password, function (error, user) {
if (!error) {
console.log('logging new registered user');
doLogin(email, password);
} else {
alert(error);
}
});
$(this).dialog("close");
},
Cancel: function () {
$(this).dialog("close");
}
}
});
$("#dialog-login").dialog({
autoOpen: false,
buttons: {
"ok": function () {
console.log('trying to login: ' + $("#login-email").val());
var email = $("#login-email").val();
var password = $("#login-password").val();
doLogin(email, password);
$(this).dialog("close");
},
Cancel: function () {
$(this).dialog("close");
}
}
});
$("#opener-register").click(function () {
$("#dialog-register").dialog("open");
});
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.