Example #1
0
 public static void LoginInBackground(string username, string password,
                                      Action <BacktoryResponse <LoginResponse> > callback)
 {
     Backtory.ExecuteAsync <LoginResponse>(LoginRequest(username, password), loginResopnse =>
     {
         // this will be called in main thread since we're using backtory API
         if (loginResopnse.Successful)
         {
             Backtory.ExecuteAsync <BacktoryUser>(UserByUsernameRequest(username, loginResopnse.Body.AccessToken), userResponse =>
             {
                 // also on main thread
                 if (userResponse.Successful)
                 {
                     //DispatchSaveCurrentUser(userResponse.Body);
                     //DispatchSaveLoginInfo(loginResopnse.Body);
                     SaveAsCurrentUserInMemoryAndStorage(userResponse.Body);
                     SaveLoginInfo(loginResopnse.Body);
                     callback(loginResopnse);
                 }
                 else
                 {
                     callback(BacktoryResponse <LoginResponse> .Unknown(userResponse.Message));
                 }
             });
         }
         else
         {
             callback(loginResopnse);
         }
     });
 }
Example #2
0
 public void ChangePasswordInBackground(string oldPassword, string newPassword, Action <BacktoryResponse <object> > callback)
 {
     if (Guest)
     {
         throw new InvalidOperationException("guest user con not change it's password");
     }
     Backtory.ExecuteAsync(ChangePassRequest(oldPassword, newPassword), callback);
 }
Example #3
0
 public void UpdateUserInBackground(Action <BacktoryResponse <BacktoryUser> > callback)
 {
     Backtory.ExecuteAsync <BacktoryUser>(UpdateUserRequest(this), updateResponse => {
         if (updateResponse.Successful)
         {
             SaveAsCurrentUserInMemoryAndStorage(updateResponse.Body);
         }
         callback(updateResponse);
     });
 }
Example #4
0
 public void CompleteRegistrationInBackgrond(GuestCompletionParam guestRegistrationParam, Action <BacktoryResponse <BacktoryUser> > callback)
 {
     Backtory.ExecuteAsync <BacktoryUser>(CompleteRegRequest(guestRegistrationParam), completeRegResponse =>
     {
         if (completeRegResponse.Successful)
         {
             SaveAsCurrentUserInMemoryAndStorage(completeRegResponse.Body);
         }
         callback(completeRegResponse);
     });
 }
Example #5
0
 public static void LogoutInBackground()
 {
     Backtory.ExecuteAsync <object>(LogoutRequest(ClearStorageAndReturnRefreshToken()), null);
 }
Example #6
0
 public void RegisterInBackground(Action <BacktoryResponse <BacktoryUser> > callback)
 {
     Backtory.ExecuteAsync(RegisterRequest(this), callback);
 }