/// <summary> /// Performs the login when the current auth status is unlocked /// Checks if the current email is the same as the email of the current registered user /// </summary> /// <param name="authStatus">The current authStatus</param> /// <param name="email">The email used for the login</param> /// <param name="password">The master password used for the login</param> /// <returns>The login result</returns> private async Task <LoginResult> LoginUnlocked(BitwardenAuthStatus authStatus, string email, string password) { if (email == authStatus.UserEmail) { //Login finished return(LoginResult.CreateSucess(authStatus.UserEmail)); } else { return(await LogoutLogin(email, password)); } }
public static async Task <LoginResult> Login() { var authStatus = await BitwardenAuthManager.GetAuthStatus(); if (authStatus.Status == BitwardenStatus.Unlocked) { //Login finished return(LoginResult.CreateSucess(authStatus.UserEmail)); } var loginResult = new LoginWindow().ShowLogin(authStatus); return(loginResult); }
/// <summary> /// Logs the user in with the email and the password /// </summary> /// <param name="email">The email of the bitwarden account</param> /// <param name="password">The password of the bitwarden account</param> /// <returns>The result of the login</returns> public override async Task <LoginResult> Login(string email, string password) { var result = await authService.Login(email, password); if (result.Output == INVALID_LOGIN) { return(LoginResult.CreateFailed(INVALID_LOGIN)); } if (result.Output.Contains(ALREADY_LOGGED_IN)) { return(LoginResult.CreateFailed(result.Output)); } //Login correct return(LoginResult.CreateSucess(email)); }
public override async Task <LoginResult> Unlock(string password) { var result = await authService.Unlock(password); if (!result.Output.Contains("--session")) { return(LoginResult.CreateFailed(result.Output)); } string session = LoginResultConverter.GetSessionKey(result.Output); Environment.SetEnvironmentVariable("BW_SESSION", session); var authResult = await GetAuthStatus(); if (authResult.Status == BitwardenStatus.Unlocked) { return(LoginResult.CreateSucess(authResult.UserEmail)); } else { return(LoginResult.CreateFailed("The vault could not be unlocked")); } }