Guest User

login.js

a guest
Apr 4th, 2016
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. $('#signup-btn').click(signUp);
  2.  
  3. function signUp(){
  4. var r = new Firebase("https://sizzling-inferno-4441.firebaseio.com");
  5. console.log("Clicked");
  6. r.createUser({
  7. email : $('#signup-username').val(),
  8. password : $('#signup-password').val(),
  9. }, function(error, userData) {
  10. if (error) {
  11. console.log("Error creating user:", error);
  12. } else {
  13. console.log("Successfully created user account with uid:", userData.uid);
  14. }
  15. });
  16. }
  17.  
  18. $('#login-btn').click(login);
  19.  
  20. function login(){
  21. var ref = new Firebase("https://sizzling-inferno-4441.firebaseio.com");
  22. ref.authWithPassword({
  23. email : $('#username').val(),
  24. password : $('#password').val(),
  25. }, function(error, authData) {
  26. if (error) {
  27. console.log("Login Failed!", error);
  28. } else {
  29. console.log("Authenticated successfully with payload:", authData);
  30. window.location.replace("./home.html");
  31. }
  32. });
  33. }
Add Comment
Please, Sign In to add comment