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:
parent
ac310889c0
commit
6d27dcbf05
2 changed files with 10 additions and 2 deletions
|
@ -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> {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue