From f581147601a131d238fc092bed0e4e78c7e89b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 26 Jan 2024 09:20:46 +0100 Subject: [PATCH] Disabled otp signin support --- app/controllers/api/account.php | 2 +- app/controllers/shared/api.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 70aef4fdc5..245cb131a5 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1213,7 +1213,7 @@ App::post('/v1/account/tokens/email') ->desc('Create email token (OTP)') ->groups(['api', 'account']) ->label('scope', 'sessions.write') - ->label('auth.type', 'email') + ->label('auth.type', 'emailOtp') ->label('audits.event', 'session.create') ->label('audits.resource', 'user/{response.userId}') ->label('audits.userId', '{response.userId}') diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 7a22af5016..121c781011 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -333,8 +333,14 @@ App::init() $auths = $project->getAttribute('auths', []); switch ($route->getLabel('auth.type', '')) { case 'emailPassword': + if (($auths['emailOtp'] ?? true) === false) { + throw new Exception(Exception::USER_AUTH_METHOD_UNSUPPORTED, 'Email OTP authentication is disabled for this project'); + } + break; + + case 'emailOtp': if (($auths['emailPassword'] ?? true) === false) { - throw new Exception(Exception::USER_AUTH_METHOD_UNSUPPORTED, 'Email / Password authentication is disabled for this project'); + throw new Exception(Exception::USER_AUTH_METHOD_UNSUPPORTED, 'Magic URL authentication is disabled for this project'); } break;