0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-04-14 23:11:31 -05:00

refactor(core): should return token object upon successful verification in experience api

This commit is contained in:
Charles Zhao 2025-03-19 12:57:32 +08:00
parent ac310889c0
commit 6d27dcbf05
No known key found for this signature in database
GPG key ID: 55CFA7C080C98029
2 changed files with 10 additions and 2 deletions

View file

@ -83,8 +83,13 @@ export class OneTimeTokenVerification
* Verifies if the one-time token matches the record in database with the provided email.
*/
async verify(token: string) {
await this.libraries.oneTimeTokens.verifyOneTimeToken(token, this.identifier.value);
const oneTimeToken = await this.libraries.oneTimeTokens.verifyOneTimeToken(
token,
this.identifier.value
);
this.verified = true;
return oneTimeToken;
}
async identifyUser(): Promise<User> {

View file

@ -1,4 +1,5 @@
import {
OneTimeTokens,
oneTimeTokenVerificationVerifyPayloadGuard,
SentinelActivityAction,
VerificationType,
@ -27,6 +28,7 @@ export default function oneTimeTokenVerificationRoutes<
body: oneTimeTokenVerificationVerifyPayloadGuard,
response: z.object({
verificationId: z.string(),
token: OneTimeTokens.guard,
}),
status: [200, 400, 404],
}),
@ -48,7 +50,7 @@ export default function oneTimeTokenVerificationRoutes<
ctx.experienceInteraction.setVerificationRecord(oneTimeTokenVerificationRecord);
await withSentinel(
const tokenRecord = await withSentinel(
{
sentinel,
action: SentinelActivityAction.OneTimeToken,
@ -65,6 +67,7 @@ export default function oneTimeTokenVerificationRoutes<
ctx.body = {
verificationId: oneTimeTokenVerificationRecord.id,
token: tokenRecord,
};
return next();