Skip to content

Commit 3b41e45

Browse files
Merge pull request #85 from Web3Auth/enableMFA_enhancements
feat: enableMFA() enhancements
2 parents 1135401 + 0872123 commit 3b41e45

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

core/src/main/java/com/web3auth/core/Web3Auth.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
314314
*/
315315
fun enableMFA(loginParams: LoginParams? = null): CompletableFuture<Boolean> {
316316
enableMfaCompletableFuture = CompletableFuture()
317+
if (web3AuthResponse?.userInfo?.isMfaEnabled == true) {
318+
throwEnableMFAError(ErrorCode.MFA_ALREADY_ENABLED)
319+
return enableMfaCompletableFuture
320+
}
317321
val sessionId = sessionManager.getSessionId()
318322
if (sessionId.isBlank()) {
319323
throwEnableMFAError(ErrorCode.NOUSERFOUND)

core/src/main/java/com/web3auth/core/types/Web3AuthError.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ object Web3AuthError {
2525
ErrorCode.INVALID_LOGIN -> {
2626
"Invalid Login"
2727
}
28+
ErrorCode.MFA_ALREADY_ENABLED -> {
29+
"MFA already enabled"
30+
}
2831
}
2932
}
3033
}
@@ -36,5 +39,6 @@ enum class ErrorCode {
3639
RUNTIME_ERROR,
3740
APP_CANCELLED,
3841
SOMETHING_WENT_WRONG,
39-
INVALID_LOGIN
42+
INVALID_LOGIN,
43+
MFA_ALREADY_ENABLED
4044
}

0 commit comments

Comments
 (0)