1
0
Fork 0
mirror of synced 2024-06-02 02:44:47 +12:00

fix(magic-url): verify e-mail address on user

This commit is contained in:
Torsten Dittmann 2021-09-01 09:29:12 +02:00
parent 5bdebe55d7
commit bcc8c0a9cd

View file

@ -795,8 +795,13 @@ App::put('/v1/account/sessions/magic-url')
->inject('geodb')
->inject('audits')
->action(function ($userId, $secret, $request, $response, $projectDB, $locale, $geodb, $audits) {
/** @var string $userId */
/** @var string $secret */
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
/** @var Utopia\Locale\Locale $locale */
/** @var MaxMind\Db\Reader $geodb */
/** @var Appwrite\Event\Event $audits */
$profile = $projectDB->getCollectionFirst([ // Get user by user ID
@ -846,6 +851,7 @@ App::put('/v1/account/sessions/magic-url')
throw new Exception('Failed saving session to DB', 500);
}
$profile->setAttribute('emailVerification', true);
$profile->setAttribute('sessions', $session, Document::SET_TYPE_APPEND);
$user = $projectDB->updateDocument($profile->getArrayCopy());
@ -853,7 +859,7 @@ App::put('/v1/account/sessions/magic-url')
if (false === $user) {
throw new Exception('Failed saving user to DB', 500);
}
if (!$projectDB->deleteDocument($token)) {
throw new Exception('Failed to remove login token from DB', 500);
}