public async void Login() { PreCadastro(); await auth.SignInWithEmailAndPasswordAsync(email.text, senha.text).ContinueWith(task => { }); if (auth.CurrentUser != null) { if (auth.CurrentUser.IsEmailVerified == false) { Logout(); PosCadastro(); Debug.Log("Email ainda nao verificado!"); } else { SceneManager.LoadScene("Usuario Logado"); } } else { Debug.Log("Email ou senha estão incorretos!"); PosCadastro(); } }
/// <summary> /// Signs the in with email and password async. /// </summary> /// <param name="email">Email.</param> /// <param name="password">Password.</param> /// <param name="onDone">On done.</param> public void SignInWithEmailAndPasswordAsync(string email, string password, System.Action <LoginResult> onDone) { Debug.Log(string.Format("Attempting to login user {0}...", email)); auth.SignInWithEmailAndPasswordAsync(email, password) .ContinueWith((authTask) => { if (authTask.IsCanceled) { Debug.Log("SignInWithEmailAndPasswordAsync canceled."); if (onDone != null) { onDone(LoginResult.CANCELLED); } } else if (authTask.IsFaulted) { Debug.Log("SignInWithEmailAndPasswordAsync encounted an error."); Debug.LogError(authTask.Exception.ToString()); if (onDone != null) { onDone(LoginResult.ERROR); } } else if (authTask.IsCompleted) { Debug.Log("SignInWithEmailAndPasswordAsync completed"); // UpdateUserProfile(newDisplayName: newDisplayName); // Firebase.Auth.FirebaseUser newUser = authTask.Result; if (onDone != null) { onDone(LoginResult.OK); } } }); }
public void SignIn() { if (!IsFirebaseReady || IsSignInOnProgress || User != null) { return; } IsSignInOnProgress = true; signInButton.interactable = false; firebaseAuth.SignInWithEmailAndPasswordAsync(emailField.text, passwordField.text).ContinueWithOnMainThread(task => { Debug.Log($"Sign in status : {task.Status}"); IsSignInOnProgress = false; signInButton.interactable = true; if (task.IsFaulted) { Debug.LogError(task.Exception); } else if (task.IsCanceled) { Debug.LogError("sign-in canceled"); } else { User = task.Result; Debug.Log(User.Email); SceneManager.LoadScene("Lobby"); } } ); }
public void emailLogin(string email, string passwd) { firebaseAuth.SignInWithEmailAndPasswordAsync(email, passwd).ContinueWith( task => { if (!task.IsFaulted && !task.IsCanceled && task.IsCompleted) { Debug.Log(email + "로그인 하셧습니다."); } else { Debug.Log("로그인에 실패 하셧씁니다."); } } ); }
public async Task <string> LoginWithEmailPasswordAsync(string email, string password) { var instance = FirebaseAuth.GetInstance(MainActivity.app); if (instance == null) { mAuth = new FirebaseAuth(MainActivity.app); } else { mAuth = instance; } IAuthResult res; try { res = await mAuth.SignInWithEmailAndPasswordAsync(email, password); } catch (Exception ex) { return(await Task.FromResult("false:" + ex.Message)); } return(null); }
public void LoginExistingUser(string email, string password) { auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => { StartCoroutine(authCallback(task, "login")); }); }
void Login(string e, string p) { try { auth.SignInWithEmailAndPasswordAsync(e, p).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception); return; } if (task.IsCompleted) { FirebaseUser newUser = task.Result; uid = newUser.UserId; //UnityMainThreadDispatcher.Instance().Enqueue(() => SignInGetUserCredentials(uid)); SignInGetUserCredentials(uid); Debug.Log(uid); Debug.LogFormat("User signed in successfully: {0} ({1})", newUser.DisplayName, newUser.UserId); } }); } catch (Exception) { } }
public void LoginToFireBase(string email, string password) { Debug.Log("Trying Login"); isLoginSucceded = false; auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => { Debug.Log(task.Status); if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync canceled."); return; } if (task.IsFaulted) { Debug.LogError("SignInWithEmailAndPasswordAsync error: " + task.Exception); if (task.Exception.InnerExceptions.Count > 0) { UpdateStatus(task.Exception.InnerExceptions[0].Message); } return; } isLoginSucceded = true; FirebaseUser user = task.Result; LoadManager.Instance.playerData.UID = user.UserId; Debug.Log("Login Complete : " + LoadManager.Instance.playerData.UID); }); if (isLoginSucceded) { } }
// 로그인 버튼 클릭 시 public void OnClickSignIn() { // 파이어베이스가 준비 안된 상태 || 이미 유저가 할당된 경우 || 이미 로그인 서비스가 실행 중인 경우 if (!IsFirebaseReady || User != null || IsSignInOnProgress == true) { return; } IsSignInOnProgress = true; signInButton.interactable = false; // 이메일 입력을 통한 로그인 firebaseAuth.SignInWithEmailAndPasswordAsync(emailField.text, passwordField.text).ContinueWithOnMainThread(task => { Debug.Log($"Sign in status : {task.Status}"); IsSignInOnProgress = false; signInButton.interactable = true; if (task.IsFaulted) { Debug.LogError("Fail to Sign-in: " + task.Exception); errorPanel.SetActive(true); } else if (task.IsCanceled) { Debug.LogError("SignIn was canceled"); } else // 로그인 성공의 경우 { User = task.Result; Debug.Log("Succeed to Sign-in: " + User.Email); SceneManager.LoadScene("Mainmenu"); } }); }
// Login User public void Login(string email, string password) { auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync canceled."); return; } if (task.IsFaulted) { Debug.LogError("SignInWithEmailAndPasswordAsync error: " + task.Exception); if (task.Exception.InnerExceptions.Count > 0) { UpdateErrorMessage(task.Exception.InnerExceptions[0].Message); } return; } FirebaseUser user = task.Result; Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId); // Load Start Scene Acync StartCoroutine(LoadStartScene()); LoginResultText.text = "Hi! " + user.DisplayName; // Debug.LogFormat("Successfully signed in as {0}", usrname); }); }
public void Login() { if (CheckLoginFields()) { //Inputlarda bir sorun yok ise inputlardaki değerler baz alınarak giriş işlemi yapılır. auth.SignInWithEmailAndPasswordAsync(loginEmail.text, loginPassword.text).ContinueWith(task => { if (task.IsCanceled) { exceptionText.text = "Login canceled."; return; } else if (task.IsFaulted) { foreach (var exception in task.Exception.Flatten().InnerExceptions) { exceptionText.text = exception.Message; } return; } FirebaseUser newUser = task.Result; }); } }
void LoginUser() { auth.SignInWithEmailAndPasswordAsync(email_login, password_login).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync was canceled."); login_panel.SetActive(true); return; } if (task.IsFaulted) { Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception); login_panel.SetActive(true); return; } Firebase.Auth.FirebaseUser newUser = task.Result; Debug.LogFormat("User signed in successfully: {0} ({1})", newUser.DisplayName, newUser.UserId); PlayerPrefs.SetString("id", email_login); PlayerPrefs.SetString("password", password_login); AuthStateChanged(this, null); this.gameObject.GetComponent <DB_control>().read(); //씬전환 AutoFade.LoadLevel("Main", 1, 1, _fadeColor); }); }
public async Task <bool> IsAuthenticatedAsync(string username, string password) { if (_firebaseAuthInstance == null) { return(false); } string result = string.Empty; try { var user = await _firebaseAuthInstance.SignInWithEmailAndPasswordAsync(username, password); var token = await user.User.GetIdTokenAsync(false); result = token.Token; } catch (FirebaseAuthInvalidCredentialsException e) { e.PrintStackTrace(); } catch (FirebaseAuthInvalidUserException e) { e.PrintStackTrace(); } return(!string.IsNullOrEmpty(result)); }
/* * Use Email Id and Password to Login Firebase */ public void LoginWithEmail(string email, string password, System.Action <string> callback) { m_auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWithOnMainThread(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPassword was canceled."); return; } else if (task.IsFaulted) { FirebaseException exception = task.Exception.InnerExceptions[0].InnerException as FirebaseException; var errCode = (AuthError)exception.ErrorCode; //callback(GetErrorMessage(errCode.ToString())); Debug.Log(errCode.ToString()); callback(errCode.ToString()); return; } else if (task.IsCompleted) { m_user = task.Result; Debug.LogFormat("User signed in successfully: {0} ({1})", m_user.DisplayName, m_user.UserId); LoadHome(1); } }); }
public void OnClick_SignIn() { auth.SignInWithEmailAndPasswordAsync(EmailInput.text, PasswordInput.text).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception); return; } Firebase.Auth.FirebaseUser newUser = task.Result; Debug.LogFormat("User signed in successfully: {0} ({1})", EmailInput.text, newUser.UserId); }); usersRef = db.Collection("users"); docRef = usersRef.Document(EmailInput.text); SaveLogin(); LoadLobby(); }
private async void LoginButton_Click(object sender, EventArgs e) { Intent result = new Intent(); try { // Attempt Login await auth.SignInWithEmailAndPasswordAsync(email.Text, password.Text); if (auth.CurrentUser != null) { result.PutExtra("isLoggedIn", true); result.PutExtra("message", "Login Successful!"); SetResult(Result.Ok, result); } else //failed login { result.PutExtra("isLoggedIn", false); result.PutExtra("message", "Login Failed"); SetResult(Result.Ok, result); } } catch (Exception ex) { result.PutExtra("isLoggedIn", false); result.PutExtra("message", ex.Message); SetResult(Result.Ok, result); } finally { //Close Activity Finish(); } }
public IEnumerator fazLogin() { string meuLogin = login.text; string minhaSenha = senha.text; var LoginTask = auth.SignInWithEmailAndPasswordAsync(meuLogin, minhaSenha); yield return(new WaitUntil(predicate: () => LoginTask.IsCompleted)); if (LoginTask.Exception != null) { SceneManager.LoadScene("erro"); FirebaseException fex = LoginTask.Exception.GetBaseException() as FirebaseException; AuthError ae = (AuthError)fex.ErrorCode; print(fex.Message); print(ae.ToString()); } else { //SceneManager.LoadScene("ok"); //LOAD DATA username = login.text; StartCoroutine(loadUserData()); //GO TO PAGE goToDatabasePage(); } }
// Start is called before the first frame update public void onSubmit() { //validateInput(); //if (validation.text == "") //{ Debug.Log("Email : " + email.text + " Password : "******"SignInWithEmailAndPasswordAsync was canceled."; Debug.LogError("SignInWithEmailAndPasswordAsync was canceled."); return; } if (task.IsFaulted) { validation.text = "SignInWithEmailAndPasswordAsync encountered an error:"; Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception); return; } Firebase.Auth.FirebaseUser newUser = task.Result; Debug.LogFormat("User signed in successfully: {0} ({1})", newUser.DisplayName, newUser.UserId); }); //} }
public void Login1(string email, string password) { auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync canceled."); return; } if (task.IsFaulted) { Debug.LogError("SignInWithEmailAndPasswordAsync error: " + task.Exception); if (task.Exception.InnerExceptions.Count > 0) { UpdateErrorMessage(task.Exception.InnerExceptions[0].Message); } return; } FirebaseUser user = task.Result; Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId); //PlayerPrefs.SetString("LoginUser", user != null ? user.Email : "Unknown"); authorization = true; username = email; }); }
public void Launch() { loadingScreen.SetActive(true); errorTextSignIn.text = ""; forgotPasswordText.color = new Color(0.7137255f, 0.6627451f, 0.7019608f); if (Username.text == "" || Password.text == "") { errorTextSignIn.text = "Please complete all fields"; loadingScreen.SetActive(false); return; } //Debug.Log("Launch Login"); email = Username.text.ToLower(); password = Password.text; string deviceModel = SystemInfo.deviceModel.ToLower(); //Amazon Device check if (!deviceModel.Contains("amazon")) { auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync was canceled."); loadingScreen.SetActive(false); return; } if (task.IsFaulted) { Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception); // Show the error if (SyncTables.internetLogin == false) { errorTextSignIn.text = "Not connected to Internet"; } else { errorTextSignIn.text = "Oops, that's not the correct email/password combination."; forgotPasswordText.color = Color.red; } loadingScreen.SetActive(false); loggedIn = false; return; } FirebaseUser newUser = task.Result; //Debug.LogFormat("User signed in successfully: {0} ({1})", newUser.DisplayName, newUser.UserId); SyncTables.firebaseUID = newUser.UserId; user = email; PlayerPrefs.SetString("Username", email); PlayerPrefs.SetString("Password", password); loggedIn = true; loggedInEmail = true; firstLoginAnalytics = true; StartCoroutine(GetUID("Email")); }); } else { StartCoroutine(SendDetails()); } }
//sign in to the firebase instance so we can read some data //Coroutine Number 1 IEnumerator signInToFirebase() { auth = FirebaseAuth.DefaultInstance; //the outside task is a DIFFERENT NAME to the anonymous inner class Task signintask = auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWithOnMainThread( signInTask => { if (signInTask.IsCanceled) { //write cancelled in the console Debug.Log("Cancelled!"); return; } if (signInTask.IsFaulted) { //write the actual exception in the console Debug.Log("Something went wrong!" + signInTask.Exception); return; } Firebase.Auth.FirebaseUser loggedInUser = signInTask.Result; Debug.Log("User " + loggedInUser.DisplayName + " has logged in!"); } ); signedin = true; yield return(new WaitUntil(() => signintask.IsCompleted)); Debug.Log("User has signed in"); }
protected void FirebaseLogin() { auth.SignInWithEmailAndPasswordAsync(Email.text, Password.text).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("The sign-in process was canceled"); return; } if (task.IsFaulted) { Debug.LogError("The sign-in process encountered a problem: " + task.Exception); return; } if (task.IsCompleted) { FirebaseUser newUser = task.Result; Debug.LogFormat("User was signed in successfully: [0] ({1})", newUser.DisplayName, newUser.UserId); user = auth.CurrentUser; if (user != null) { loadScene = true; } } }); }
public void DoLogin() { var email = emailForm.text; var password = passwordForm.text; if (email.Length > 0 && password.Length > 0) { auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => { if (task.IsCanceled) { Debug.Log("Login Cancelled!"); return; } if (task.IsFaulted) { Debug.Log("Login Faulted!"); return; } var newUser = task.Result; Debug.LogFormat("Başarıyla giriş yapıldı: {0} {1}", newUser.DisplayName, newUser.UserId); }); } else { Debug.Log("Form alanlarını boş bırakmayınız!"); } }
async public void SignIn() { await auth.SignInWithEmailAndPasswordAsync(UserInput.text, PassInput.text).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync was canceled."); _SignedInFlag = false; return; } if (task.IsFaulted) { Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception); _SignedInFlag = false; return; } newUser = task.Result; Debug.LogFormat("User signed in successfully: {0} ({1})", newUser.DisplayName, newUser.UserId); _SignedInFlag = true; }); if (_SignedInFlag) { ProgressInterface(LoginPanel, AdminPanel); OutputText.text = "Success!"; OutputText.color = Color.green; } else { OutputText.text = "Failed Login!"; OutputText.color = Color.red; } StartCoroutine(ResetText()); }
//----------------------------------------------------------------------------------------------------------------------------------------------// public void SignInUser(string email, string password) { loading = true; auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(async(task) => { if (task.IsCanceled) { await new WaitForUpdate(); loading = false; //debug.UpdateReport ((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond).ToString (), "Your password was not changed due to the process being cancelled part way through.", debug.red); messaging.SetMessage("Process Cancelled.", "Signing in has failed due to the process being cancelled part way through.", true); return; } if (task.IsFaulted) { await new WaitForUpdate(); loading = false; messaging.SetMessage("An error has been encountered.", "Signing in has failed due to the following error: " + task.Exception.GetBaseException(), true); return; } await new WaitForUpdate(); Firebase.Auth.FirebaseUser newUser = task.Result; SaveUser(email, password); loading = false; transform.GetComponent <DataGetSet> ().GetUserInfo(); transform.GetComponent <DataGetSet> ().currentUserID = currentUser.UserId; sceneManager.OpenMenu(2); }); }
public void SignIn(string email, string password) { auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync was canceled."); return; } if (task.IsFaulted) { int errorCode = GetFirebaseErrorCode(task.Exception); switch (errorCode) { case (int)Firebase.Auth.AuthError.EmailAlreadyInUse: Debug.LogError("Email already in use"); break; case (int)AuthError.WrongPassword: Debug.LogError("Wrong password"); break; } Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception); return; } // Firebase user has been created. Firebase.Auth.FirebaseUser newUser = task.Result; Debug.LogFormat("Use signed in successfully: {0} ({1})", newUser.DisplayName, newUser.UserId); }); }
public FirebaseAuther auth() { if (initCB.isDone()) { return(this); } FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance; auth.SignInWithEmailAndPasswordAsync(email, pass).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + task.Exception); return; } user = task.Result; UnityMainThreadDispatcher.uniRxRun(() => { initCB.done(); Debug.Log("auth.done"); }); Debug.LogFormat("Firebase user login successfully: {0} ({1})", user.DisplayName, user.UserId); }); return(this); }
/// <summary> /// perform authentication to allow user login to our system /// </summary> /// <param name="email">user's email</param> /// <param name="password">user's password</param> /// <param name="callback">callback to notify caller when task is finished</param> /// <remarks> /// user is not allow to login if his email is not verified /// </remarks> /// <exception cref="System.ArgumentNullException">Thrown when callback not provided</exception> public void doLogin(string email, string password, Action <bool, string> callback) { if (callback == null) { throw new ArgumentNullException("callback is not provided"); } FirebaseAuth auth = FirebaseAuth.DefaultInstance; auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWithOnMainThread(task => { string message = readError(task); if (message != null) { callback(false, message); return; } Firebase.Auth.FirebaseUser user = task.Result; Debug.LogFormat("user found: {0} ({1})", user.DisplayName, user.UserId); if (!user.IsEmailVerified) { message = "Please verify your email"; callback(false, message); return; } message = "Authenticate successfully"; callback(true, message); }); }
void DefaultLogin(string email, string password) { auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync canceled."); return; } if (task.IsFaulted) { Debug.LogError("SignInWithEmailAndPasswordAsync error: " + task.Exception); if (task.Exception.InnerExceptions.Count > 0) { return; } } user = task.Result; Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId); SceneManager.UnloadSceneAsync(0); SceneManager.LoadScene(1, LoadSceneMode.Additive); }); }
public void LogIn() { auth.SignInWithEmailAndPasswordAsync(LogInEmail.text, LogInPassword.text).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception); return; } Firebase.Auth.FirebaseUser newUser = task.Result; Debug.LogFormat("User signed in successfully: {0} ({1})", newUser.DisplayName, newUser.UserId); UserName = newUser.UserId; Debug.Log("za da se predade " + newUser.UserId); Debug.Log("USER NAME " + UserName); }); // TimeManager.Instance.canCount = 1; UIManager.Instance.CloseLogRegUI(); SetLogInCreds(); }