Ejemplo n.º 1
0
 public async Task <ResponseData <User> > SignIn(FirebaseAuthType type, User user = null, string accessToken = null)
 {
     if (user != null && !user.Email.Equals("") && !user.Password.Equals(""))
     {
         return(await _auth.SignIn(type, accessToken, user));
     }
     else
     {
         var response = new ResponseData <User>
         {
             statusCode = MOV.Models.Constants.CODE_NOT_FOUND,
             Msg        = "Missing Data",
             data       = null
         };
         var tsk = newMethod();
         return(await tsk);
     }
 }
Ejemplo n.º 2
0
        private async void btnSignIn_Click(object sender, EventArgs e)
        {
            String email     = txtEmail.Text;
            String password  = txtPassword.Text;
            var    userLogin = new User()
            {
                Email    = email,
                Password = password
            };

            loadingView.Visible = true;

            Task <ResponseData <User> > newUser      = _authentication.SignIn(FirebaseAuthType.EmailAndPassword, userLogin, null);
            ResponseData <User>         responseData = await newUser;

            loadingView.Visible = false;
            if (responseData.statusCode == Constants.CODE_SUCCESS)
            {
                // MessageBox.Show("Hi " + responseData.data.DisplayName);
                new FormMain().Show();
            }
            else
            {
                MessageBox.Show(responseData.Msg);
            }

            //Task < ResponseData < bool >> signUpUser = _authentication.ForgotPassword("*****@*****.**");
            //ResponseData<bool> responseDataSignUp = await signUpUser;
            //loadingView.Visible = false;
            //if (responseDataSignUp.statusCode == Constants.CODE_SUCCESS)
            //{
            //    MessageBox.Show("Hi " + responseDataSignUp.data);
            //}
            //else
            //{
            //    MessageBox.Show(responseDataSignUp.Msg);
            //}
        }
Ejemplo n.º 3
0
        Task <ResponseData <bool> > IAuthentication.SignUp(FirebaseAuthType type, string accessToken, User user)
        {
            var response = new ResponseData <bool>
            {
                data       = true,
                statusCode = 200,
                Msg        = "success"
            };

            return(new Task <ResponseData <bool> >(() => response));
        }
Ejemplo n.º 4
0
        public async Task <ResponseData <User> > SignIn(FirebaseAuthType type, string accessToken, User user)
        {
            var response = new ResponseData <User>
            {
                data       = user,
                statusCode = 200,
                Msg        = "success"
            };

            return(response);
        }
Ejemplo n.º 5
0
 public async Task <ResponseData <bool> > SignUp(FirebaseAuthType type, string accessToken, User user)
 {
     return(await _auth.SignUp(type, accessToken, user));
 }
Ejemplo n.º 6
0
        public async Task <ResponseData <bool> > SignUp(FirebaseAuthType type, string accessToken, User user = null)
        {
            var response = new ResponseData <bool>
            {
                Msg        = "success",
                statusCode = 200
            };

            switch (type)
            {
            case FirebaseAuthType.EmailAndPassword:
            {
                var signUpTask = _provider.CreateUserWithEmailAndPasswordAsync(user.Email, user.Password, user.DisplayName);
                await signUpTask.ContinueWith((task) =>
                    {
                        if (!task.IsFaulted && task.Result != null)
                        {
                            var result    = task.Result;
                            response.data = true;
                        }
                        else
                        {
                            response.data       = false;
                            response.statusCode = CodeDao.MOV.Models.Constants.CODE_AUTH;
                            //     response.Msg =( (FirebaseAuthException) (task.Exception.InnerException) ).Reason.ToString();
                        }
                    });

                return(response);
            }
            }
            return(response);
        }
Ejemplo n.º 7
0
        public async Task <ResponseData <User> > SignIn(FirebaseAuthType type, string accessToken, User user = null)
        {
            var response = new ResponseData <User>
            {
                Msg        = "success",
                statusCode = 200
            };

            switch (type)
            {
            case FirebaseAuthType.EmailAndPassword:
            {
                try
                {
                    Task <FirebaseAuthLink> authTask = _provider.SignInWithEmailAndPasswordAsync(user.Email, user.Password);
                    FirebaseAuthLink        authLink = await authTask;
                    if (authLink.FirebaseToken != null)
                    {
                        string idAuth = authLink.User.LocalId;
                        var    client = new FirebaseClient(Constants.FIREBASE_URL_ROOT);

                        var userInfor = await client.Child("users")
                                        .Child(idAuth)
                                        .WithAuth(() => authLink.FirebaseToken)
                                        .OnceSingleAsync <User>();

                        response.data = userInfor;
                        return(response);
                    }
                    response.statusCode = MOV.Models.Constants.CODE_NOT_FOUND;
                    response.Msg        = MOV.Models.Constants.MSG_AUTH;
                    return(response);
                }
                catch (FirebaseException firebaseException)
                {
                    Console.WriteLine(firebaseException.Message);
                    response.Msg        = firebaseException.Message;
                    response.statusCode = firebaseException.GetHashCode();
                    return(response);
                }
                catch (FirebaseAuthException firebaseAuthException)
                {
                    Console.WriteLine(firebaseAuthException.Reason);
                    response.Msg        = firebaseAuthException.Reason.ToString();
                    response.statusCode = firebaseAuthException.Reason.GetHashCode();
                    return(response);
                }
            }

            case FirebaseAuthType.Facebook:
            {
                return(response);
            }

            case FirebaseAuthType.Google:
            {
                return(response);
            }
            }
            return(response);
        }