refactor: identity -> iam
This commit is contained in:
16
modules/iam/routes/login/code/handle.ts
Normal file
16
modules/iam/routes/login/code/handle.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { NotFoundError } from "@platform/relay";
|
||||
|
||||
import { auth } from "../../../services/auth.ts";
|
||||
import { logger } from "../../../services/logger.ts";
|
||||
import route from "./spec.ts";
|
||||
|
||||
export default route.access("public").handle(async ({ body: { email, otp } }) => {
|
||||
const response = await auth.api.signInEmailOTP({ body: { email, otp }, asResponse: true, returnHeaders: true });
|
||||
if (response.status !== 200) {
|
||||
logger.error("OTP Signin Failed", await response.json());
|
||||
return new NotFoundError();
|
||||
}
|
||||
return new Response(null, {
|
||||
headers: response.headers,
|
||||
});
|
||||
});
|
||||
14
modules/iam/routes/login/code/spec.ts
Normal file
14
modules/iam/routes/login/code/spec.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { route } from "@platform/relay";
|
||||
import z from "zod";
|
||||
|
||||
export default route
|
||||
.post("/api/v1/identity/login/code")
|
||||
.body(
|
||||
z.strictObject({
|
||||
email: z.string(),
|
||||
otp: z.string(),
|
||||
}),
|
||||
)
|
||||
.query({
|
||||
next: z.string().optional(),
|
||||
});
|
||||
Reference in New Issue
Block a user