mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-11 08:48:33 -04:00
Refactor (#1347)
This commit is contained in:
@@ -624,24 +624,16 @@ class VaultStore(
|
||||
|
||||
/**
|
||||
* Authenticate the user using biometric authentication only.
|
||||
* Note: This method only handles biometric authentication. If PIN is enabled,
|
||||
* this will return false and the caller should use showPinUnlock instead.
|
||||
* Note: This method only handles biometric authentication.
|
||||
* Returns true if authentication succeeded, false otherwise.
|
||||
*
|
||||
* @param title The title for authentication. Optional, defaults to "Unlock Vault".
|
||||
* @param subtitle The subtitle for authentication. Optional, defaults to title or "Unlock Vault".
|
||||
* @return True if biometric authentication succeeded, false if PIN is enabled or authentication failed.
|
||||
* @return True if biometric authentication succeeded, false if authentication failed.
|
||||
*/
|
||||
suspend fun authenticateUser(title: String?, subtitle: String?): Boolean {
|
||||
suspend fun issueBiometricAuthentication(title: String?): Boolean {
|
||||
// Use title if provided, otherwise default
|
||||
val authReason = title?.takeIf { it.isNotEmpty() } ?: "Unlock Vault"
|
||||
|
||||
// Check if PIN is enabled - if so, return false (caller should use PIN UI)
|
||||
if (isPinEnabled()) {
|
||||
Log.d("VaultStore", "PIN authentication is enabled, returning false")
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if biometric authentication is enabled
|
||||
val authMethods = auth.getAuthMethods()
|
||||
val isBiometricEnabled = authMethods.contains("faceid")
|
||||
|
||||
@@ -975,7 +975,7 @@ public class VaultManager: NSObject {
|
||||
}
|
||||
} else {
|
||||
// Use biometric authentication
|
||||
let authenticated = vaultStore.authenticateUser(title: title, subtitle: subtitle)
|
||||
let authenticated = vaultStore.issueBiometricAuthentication(title: title)
|
||||
resolve(authenticated)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,21 +43,13 @@ extension VaultStore {
|
||||
}
|
||||
|
||||
/// Authenticate the user using biometric authentication only
|
||||
/// Note: This method only handles biometric authentication. If PIN is enabled,
|
||||
/// this will return false and the caller should use showPinUnlock instead.
|
||||
/// Note: This method only handles biometric authentication.
|
||||
/// Returns true if authentication succeeded, false otherwise
|
||||
/// - Parameter title: The title for authentication. Optional, defaults to "Unlock Vault" context.
|
||||
/// - Parameter subtitle: The subtitle for authentication. Optional, defaults to title or "Unlock Vault" context.
|
||||
public func authenticateUser(title: String?, subtitle: String?) -> Bool {
|
||||
public func issueBiometricAuthentication(title: String?) -> Bool {
|
||||
// Use title if provided, otherwise default
|
||||
let authReason = (title?.isEmpty == false) ? title! : "Unlock Vault"
|
||||
|
||||
// Check if PIN is enabled - if so, return false (caller should use PIN UI)
|
||||
if isPinEnabled() {
|
||||
print("PIN authentication is enabled, returning false")
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if biometric authentication is enabled
|
||||
guard self.enabledAuthMethods.contains(.faceID) else {
|
||||
print("No authentication method enabled")
|
||||
|
||||
@@ -32,7 +32,7 @@ public class PasswordLockoutTests : AdminPlaywrightTest
|
||||
{
|
||||
await Page.Locator("input[id='username']").FillAsync(TestUserUsername);
|
||||
await Page.Locator("input[id='password']").FillAsync("wrongpassword");
|
||||
var submitButton = Page.Locator("#login-button");
|
||||
var submitButton = Page.GetByRole(AriaRole.Button, new() { Name = "Login" });
|
||||
await submitButton.ClickAsync();
|
||||
|
||||
// Wait for the text "Error: Invalid login attempt." to appear if we expect not to be locked out yet..
|
||||
|
||||
@@ -62,7 +62,7 @@ public class TwoFactorAuthLockoutTests : AdminPlaywrightTest
|
||||
{ "password", TestUserPassword },
|
||||
});
|
||||
|
||||
submitButton = Page.Locator("#login-button");
|
||||
submitButton = Page.GetByRole(AriaRole.Button, new() { Name = "Login" });
|
||||
await submitButton.ClickAsync();
|
||||
|
||||
// Wait for 2FA page.
|
||||
|
||||
Reference in New Issue
Block a user