예제 #1
0
  public static void login(
      final String email, final String password, final RibbitResultListener resultListener) {
    mLoginState = NOT_LOGGED_IN;
    mLoginStateTry = 0;
    RibbitBase.getRoot()
        .authWithPassword(
            email,
            password,
            new Firebase.AuthResultHandler() {
              @Override
              public void onAuthenticated(AuthData authData) {
                final String uid = authData.getUid();

                Firebase firebaseUser = getFirebaseUsers().child("/" + uid);
                firebaseUser.addListenerForSingleValueEvent(
                    new LoginUserValueListener(uid, resultListener));

                Firebase firebaseFriend = RibbitFriend.getFirebaseFriend().child("/" + uid);
                firebaseFriend.addListenerForSingleValueEvent(
                    new FriendValueListener(resultListener));
              }

              @Override
              public void onAuthenticationError(FirebaseError e) {
                Log.e(TAG, "login error " + e.getCode());
                resultListener.onFinish();
                resultListener.onError(e.toException(), e.getMessage());
              }
            });
  }
예제 #2
0
  // fresh login from sign up
  public static void firstLogin(
      final String email, final String password, final RibbitResultListener resultListener) {
    RibbitBase.getRoot()
        .authWithPassword(
            email,
            password,
            new Firebase.AuthResultHandler() {

              @Override
              public void onAuthenticated(AuthData authData) {
                Log.d(TAG, "first time login success with uid" + authData.getUid());
                resultListener.onFinish();
                resultListener.onSuccess();
              }

              @Override
              public void onAuthenticationError(FirebaseError e) {
                Log.i(TAG, "first time login failed" + e.getMessage());
                deleteUser(email, password, resultListener);
              }
            });
  }
예제 #3
0
 public static void logout() {
   RibbitBase.getRoot().unauth();
   clearCurrentUser();
   RibbitPhone.clearCandidateData();
   RibbitFriend.clearFriendData();
 }