public static async Task <bool> DoLogin <T>( T vm, AuthenticateResult resp, LoginManager loginMgr, AuthApi authApi) where T : BaseLoginViewModel, IErrorOverlayOwner { if (resp.IsSuccess) { var loginInfo = resp.LoginInfo; var oldLogin = loginMgr.Logins.Lookup(loginInfo.UserId); if (oldLogin.HasValue) { // Already had this login, apparently. // Thanks user. // // Log the OLD token out since we don't need two of them. // This also has the upside of re-available-ing the account // if the user used the main login prompt on an account we already had, but as expired. await authApi.LogoutTokenAsync(oldLogin.Value.LoginInfo.Token.Token); loginMgr.ActiveAccountId = loginInfo.UserId; loginMgr.UpdateToNewToken(loginMgr.ActiveAccount !, loginInfo.Token); return(true); } loginMgr.AddFreshLogin(loginInfo); loginMgr.ActiveAccountId = loginInfo.UserId; return(true); } vm.OverlayControl = new AuthErrorsOverlayViewModel(vm, "Unable to log in", resp.Errors); return(false); }
public async void LogoutPressed() { IsDropDownOpen = false; if (_loginMgr.ActiveAccount != null) { await _authApi.LogoutTokenAsync(_loginMgr.ActiveAccount.LoginInfo.Token.Token); _cfg.RemoveLogin(_loginMgr.ActiveAccount.LoginInfo); } }