Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. .factory('AuthService',function($firebaseAuth,$firebaseArray,$rootScope,$state,$ ionicLoading,$ionicPopup,$http,$window){
  2. var ref = new Firebase("https://cc-bloodapp.firebaseio.com/" + 'newUser');
  3. var authUser = $firebaseAuth(ref);
  4. var authRef = $firebaseArray(ref);
  5.  
  6. return{
  7.  
  8. doSignup : function(username,email,phone,state,district,city,bloodgroup,communication,wish,password){
  9.  
  10.  
  11. ref.orderByChild("phone").equalTo(phone).on('value',function(snapshot){
  12. var alreadySignedIn = snapshot.val();
  13. console.log(alreadySignedIn);
  14. if(alreadySignedIn){
  15. $ionicPopup.alert({
  16. title:'Error Signing In',
  17. template:'User already exists! try logging in!'
  18. });
  19. }
  20. else{
  21. authRef.$add({
  22. username:username,
  23. email:email,
  24. phone:phone,
  25. state:state,
  26. district:district,
  27. city:city,
  28. bloodgroup:bloodgroup,
  29. communication:communication,
  30. wish:wish,
  31. password:password
  32.  
  33. }).then(function(){
  34. $ionicPopup.alert({
  35. title:'Success',
  36. template:'User added Successfully'
  37. });
  38.  
  39. }).then(function(){
  40. ref.on("child_added", function(snapshot) {
  41. var signedUsers = snapshot.val();
  42. //console.log(signedUsers);
  43. }, function (errorObject) {
  44. console.log("The read failed: " + errorObject.code);
  45. });
  46. });
  47. }
  48. })
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement