Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .factory('AuthService',function($firebaseAuth,$firebaseArray,$rootScope,$state,$ ionicLoading,$ionicPopup,$http,$window){
- var ref = new Firebase("https://cc-bloodapp.firebaseio.com/" + 'newUser');
- var authUser = $firebaseAuth(ref);
- var authRef = $firebaseArray(ref);
- return{
- doSignup : function(username,email,phone,state,district,city,bloodgroup,communication,wish,password){
- ref.orderByChild("phone").equalTo(phone).on('value',function(snapshot){
- var alreadySignedIn = snapshot.val();
- console.log(alreadySignedIn);
- if(alreadySignedIn){
- $ionicPopup.alert({
- title:'Error Signing In',
- template:'User already exists! try logging in!'
- });
- }
- else{
- authRef.$add({
- username:username,
- email:email,
- phone:phone,
- state:state,
- district:district,
- city:city,
- bloodgroup:bloodgroup,
- communication:communication,
- wish:wish,
- password:password
- }).then(function(){
- $ionicPopup.alert({
- title:'Success',
- template:'User added Successfully'
- });
- }).then(function(){
- ref.on("child_added", function(snapshot) {
- var signedUsers = snapshot.val();
- //console.log(signedUsers);
- }, function (errorObject) {
- console.log("The read failed: " + errorObject.code);
- });
- });
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement