mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-08 20:25:19 +02:00
refactor auth types
This commit is contained in:
parent
81ee04c2a5
commit
82fea0ceee
1 changed files with 16 additions and 20 deletions
|
|
@ -1,33 +1,29 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const loginRequest = z.object({
|
||||
email: z.string().email(),
|
||||
password: z.string().min(1),
|
||||
grant_type: z.string().optional(),
|
||||
email: z.string().email(),
|
||||
password: z.string().min(3),
|
||||
grant_type: z.string().optional(),
|
||||
});
|
||||
|
||||
export const loginResponse = z.object({
|
||||
access_token: z.string(),
|
||||
token_type: z.string(),
|
||||
access_token: z.string(),
|
||||
token_type: z.string(),
|
||||
});
|
||||
|
||||
export const registerRequest = z.object({
|
||||
email: z.string().email(),
|
||||
password: z.string().min(1),
|
||||
is_active: z.boolean().optional(),
|
||||
is_superuser: z.boolean().optional(),
|
||||
is_verified: z.boolean().optional(),
|
||||
export const registerRequest = loginRequest.omit({ grant_type: true }).extend({
|
||||
is_active: z.boolean().optional(),
|
||||
is_superuser: z.boolean().optional(),
|
||||
is_verified: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const registerResponse = z.object({
|
||||
id: z.number(),
|
||||
email: z.string().email(),
|
||||
is_active: z.boolean(),
|
||||
is_superuser: z.boolean(),
|
||||
is_verified: z.boolean(),
|
||||
pages_limit: z.number(),
|
||||
pages_used: z.number(),
|
||||
});
|
||||
export const registerResponse = registerRequest
|
||||
.omit({ password: true })
|
||||
.extend({
|
||||
id: z.number(),
|
||||
pages_limit: z.number(),
|
||||
pages_used: z.number(),
|
||||
});
|
||||
|
||||
export type LoginRequest = z.infer<typeof loginRequest>;
|
||||
export type LoginResponse = z.infer<typeof loginResponse>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue