public static FirebaseUserResult CreateCanceledResult() { FirebaseUserResult result = new FirebaseUserResult(); result.IsCanceled = true; return(result); }
public static FirebaseUserResult CreateFaultedResult(Exception exception) { FirebaseUserResult result = new FirebaseUserResult(); result.IsFaulted = true; result.Exception = exception; return(result); }
public void SignOut() { if (auth != null) { auth.SignOut(); } currentUser = null; currentToken = null; stsTokenManager = null; }
public static FirebaseUserResult CreateSuccessResult(string uid, string displayName, string photoUrl, string email, bool isEmailVerified, bool isAnonymous) { FirebaseUserResult result = new FirebaseUserResult(); result.UserId = uid; result.DisplayName = displayName; result.PhotoUrl = string.IsNullOrEmpty(photoUrl) ? null : new Uri(photoUrl); result.Email = email; result.IsEmailVerified = isEmailVerified; result.IsAnonymous = isAnonymous; return(result); }
public static FirebaseUserResult CreateResultByUser(FirebaseUser user) { FirebaseUserResult result = new FirebaseUserResult(); result.UserId = user.UserId; result.DisplayName = user.DisplayName; result.PhotoUrl = user.PhotoUrl; result.Email = user.Email; result.IsEmailVerified = user.IsEmailVerified; result.IsAnonymous = user.IsAnonymous; return(result); }
// Track state changes of the auth object. private void AuthStateChanged(object sender, System.EventArgs eventArgs) { bool signedIn = user != auth.CurrentUser && auth.CurrentUser != null; if (!signedIn && user != null) { Debug.Log("Signed out " + user.UserId); } user = auth.CurrentUser; if (currentUser != null) { currentUser = FirebaseUserResult.CreateResultByUser(user); } else { currentUser = null; } if (signedIn) { Debug.Log("Signed in " + user.UserId); } }
public IEnumerator ProcessFirebaseUserTaskRoutine(Task <FirebaseUser> t, Action <FirebaseUserResult> callback) { while (!t.IsCompleted) { yield return(null); } if (callback != null) { if (t.IsFaulted) { callback(FirebaseUserResult.CreateFaultedResult(t.Exception)); } else if (t.IsCanceled) { callback(FirebaseUserResult.CreateCanceledResult()); } else { currentUser = FirebaseUserResult.CreateResultByUser(user); callback(currentUser); } } }
public IEnumerator ProcessWebServiceUserRoutine(WWW www, Action <FirebaseUserResult> callback) { yield return(www); if (callback != null) { if (!string.IsNullOrEmpty(www.error)) { currentUser = null; currentToken = null; stsTokenManager = null; callback(FirebaseUserResult.CreateFaultedResult(new Exception(www.error))); } else { // Parsing json var result = MiniJSON.Json.Deserialize(www.text) as Dictionary <string, object>; stsTokenManager = result["stsTokenManager"] as Dictionary <string, object>; currentUser = FirebaseUserResult.CreateSuccessResult(result.GetString("uid"), result.GetString("displayName"), result.GetString("photoURL"), result.GetString("email"), result.GetBool("emailVerified"), result.GetBool("isAnonymous")); currentToken = FirebaseUserTokenResult.CreateSuccessResult(stsTokenManager.GetString("accessToken")); callback(currentUser); } } }
public void OnDestroy() { auth.StateChanged -= AuthStateChanged; auth = null; currentUser = null; }