/// <summary> /// Logout the user from the bitwarden. /// </summary> /// <returns>True if user was logged out.</returns> public bool Logout() { IsUserLoggedIn = !_logic.Logout(); ConsoleDebugLogger.Log(string.Format("Logout {0}", !IsUserLoggedIn ? "successful" : "failed")); if (!IsUserLoggedIn && IsVaultUnlocked) { IsVaultUnlocked = false; UserEmail = string.Empty; } return(!IsUserLoggedIn); }
/// <summary> /// Unlock the user vault. /// </summary> /// <returns>True if the vault was unlocked.</returns> public bool UnlockVault() { if (!IsUserLoggedIn) { ConsoleDebugLogger.LogError("Cann't unlock the vault because the user is not logged in."); return(false); } IsVaultUnlocked = _logic.UnlockVault(_credentials); ConsoleDebugLogger.Log(string.Format("Unlocking vault {0}", IsVaultUnlocked ? "successful" : "failed")); return(IsVaultUnlocked); }
public void Dispose() { ConsoleDebugLogger.Log("Disposing BitwardenClient"); if (IsVaultUnlocked) { ConsoleDebugLogger.Log("[Dispose] Locking unlocked vault."); _logic.LockVault(); } if (!_stayLogged) { ConsoleDebugLogger.Log("[Dispose] Logging off (_stayLogged = false)."); _logic.Logout(); } }
private bool CheckUnlockedVault() { if (!IsUserLoggedIn) { ConsoleDebugLogger.LogError("[CheckUnlockedVault] The user is not logged in."); return(false); } if (!IsVaultUnlocked) { ConsoleDebugLogger.LogError("[CheckUnlockedVault] The vault is not unlocked."); return(false); } return(true); }
/// <summary> /// Login user to the bitwarden. This does not unlock the vault. /// </summary> /// <returns>True if login was successful.</returns> public bool Login() { // Check if someone is already logged. if (CheckForLoggedUser()) { // If someone is logged and it is different user logout him and chage UserEmail. if (UserEmail != _credentials.Email) { Logout(); UserEmail = _credentials.Email; } else { ConsoleDebugLogger.Log($"User {UserEmail} is already logged in."); return(true); } } IsUserLoggedIn = _logic.Login(_credentials); ConsoleDebugLogger.Log(string.Format("Login {0}", IsUserLoggedIn ? "successful" : "failed")); return(IsUserLoggedIn); }
/// <summary> /// Lock the user vault. /// </summary> /// <returns>True if the vault was locked.</returns> public bool LockVault() { IsVaultUnlocked = !_logic.LockVault(); ConsoleDebugLogger.Log(string.Format("Locking vault {0}", !IsVaultUnlocked ? "successful" : "failed")); return(!IsVaultUnlocked); }