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); } }); }
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); }
public void UpdateUserInBackground(Action <BacktoryResponse <BacktoryUser> > callback) { Backtory.ExecuteAsync <BacktoryUser>(UpdateUserRequest(this), updateResponse => { if (updateResponse.Successful) { SaveAsCurrentUserInMemoryAndStorage(updateResponse.Body); } callback(updateResponse); }); }
public void CompleteRegistrationInBackgrond(GuestCompletionParam guestRegistrationParam, Action <BacktoryResponse <BacktoryUser> > callback) { Backtory.ExecuteAsync <BacktoryUser>(CompleteRegRequest(guestRegistrationParam), completeRegResponse => { if (completeRegResponse.Successful) { SaveAsCurrentUserInMemoryAndStorage(completeRegResponse.Body); } callback(completeRegResponse); }); }
public static void LogoutInBackground() { Backtory.ExecuteAsync <object>(LogoutRequest(ClearStorageAndReturnRefreshToken()), null); }
public void RegisterInBackground(Action <BacktoryResponse <BacktoryUser> > callback) { Backtory.ExecuteAsync(RegisterRequest(this), callback); }