Esempio n. 1
0
        public async Task <IFirebaseUser> SignInWithEmailAndPasswordAsync(string email, string password, bool createsUserAutomatically = true)
        {
            try {
                var credential = await _emailAuth.GetCredentialAsync(email, password);

                return(await SignInWithCredentialAsync(credential));
            } catch (NSErrorException e) {
                if (e.Code == (long)AuthErrorCode.UserNotFound && createsUserAutomatically)
                {
                    await CreateUserAsync(email, password);

                    return(await SignInWithEmailAndPasswordAsync(email, password));
                }
                throw new FirebaseException(e.Error?.LocalizedDescription);
            }
        }
        public async Task <IFirebaseUser> SignInWithEmailAndPasswordAsync(string email, string password, bool createsUserAutomatically = true)
        {
            try {
                var credential = await _emailAuth.GetCredentialAsync(email, password);

                return(await SignInWithCredentialAsync(credential));
            } catch (FirebaseAuthInvalidUserException e) {
                if (createsUserAutomatically)
                {
                    await CreateUserAsync(email, password);

                    return(await SignInWithEmailAndPasswordAsync(email, password));
                }
                throw new FirebaseException(e.Message);
            }
        }