diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index c1dcafa7a..3ced3d069 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -698,6 +698,7 @@ App::post('/v1/account/sessions/magic-url') Authorization::reset(); $mails->setParam('event', 'users.create'); + $audits->setParam('event', 'users.create'); } $loginSecret = Auth::tokenGenerator(); @@ -740,7 +741,6 @@ App::post('/v1/account/sessions/magic-url') $url = Template::unParseURL($url); $mails - ->setParam('event', ($userAdded ?? false) ? 'users.create' : '') ->setParam('from', $project->getId()) ->setParam('recipient', $user->getAttribute('email')) ->setParam('url', $url) @@ -763,7 +763,6 @@ App::post('/v1/account/sessions/magic-url') $audits ->setParam('userId', $user->getId()) - ->setParam('event', ($userAdded ?? false) ? 'users.create' : '') ->setParam('resource', 'users/'.$user->getId()) ; diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 0df72d057..c3134b4f8 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -141,6 +141,12 @@ App::init(function ($utopia, $request, $response, $project, $user) { } break; + case 'magic-url': + if($project->getAttribute('usersAuthMagicURL', true) === false) { + throw new Exception('Magic URL authentication is disabled for this project', 501); + } + break; + case 'anonymous': if($project->getAttribute('usersAuthAnonymous', true) === false) { throw new Exception('Anonymous authentication is disabled for this project', 501);