aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2020-04-24 15:00:33 +0530
committerGitHub <noreply@github.com>2020-04-24 15:00:33 +0530
commit73695e2493af46c2375bb7678cb879d33a8aed4f (patch)
tree218cdd48c75e64bd7945b46622ef15ea161d72c0 /app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt
parentbee20ac44a6b03082ee85cb52db4d8f32e2dd899 (diff)
downloadHardenedPass-73695e2493af46c2375bb7678cb879d33a8aed4f.tar.gz
HardenedPass-73695e2493af46c2375bb7678cb879d33a8aed4f.zip
auth: redo implementation with a cleaner and simpler API surface (#741)
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt18
1 files changed, 10 insertions, 8 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt b/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt
index 7db8cd48..b5902199 100644
--- a/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt
@@ -8,10 +8,10 @@ import android.content.Intent
import android.os.Bundle
import android.os.Handler
import androidx.appcompat.app.AppCompatActivity
+import androidx.core.content.edit
import androidx.preference.PreferenceManager
import com.zeapo.pwdstore.crypto.PgpActivity
-import com.zeapo.pwdstore.utils.auth.AuthenticationResult
-import com.zeapo.pwdstore.utils.auth.Authenticator
+import com.zeapo.pwdstore.utils.BiometricAuthenticator
class LaunchActivity : AppCompatActivity() {
@@ -19,18 +19,20 @@ class LaunchActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
if (prefs.getBoolean("biometric_auth", false)) {
- Authenticator(this) {
+ BiometricAuthenticator.authenticate(this) {
when (it) {
- is AuthenticationResult.Success -> {
+ is BiometricAuthenticator.Result.Success -> {
startTargetActivity(false)
}
- is AuthenticationResult.UnrecoverableError -> {
- finish()
+ is BiometricAuthenticator.Result.HardwareUnavailableOrDisabled -> {
+ prefs.edit { remove("biometric_auth") }
+ startTargetActivity(false)
}
- else -> {
+ is BiometricAuthenticator.Result.Failure, BiometricAuthenticator.Result.Cancelled -> {
+ finish()
}
}
- }.authenticate()
+ }
} else {
startTargetActivity(true)
}