mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-10 22:32:16 +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";
|
import { z } from "zod";
|
||||||
|
|
||||||
export const loginRequest = z.object({
|
export const loginRequest = z.object({
|
||||||
email: z.string().email(),
|
email: z.string().email(),
|
||||||
password: z.string().min(1),
|
password: z.string().min(3),
|
||||||
grant_type: z.string().optional(),
|
grant_type: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const loginResponse = z.object({
|
export const loginResponse = z.object({
|
||||||
access_token: z.string(),
|
access_token: z.string(),
|
||||||
token_type: z.string(),
|
token_type: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const registerRequest = z.object({
|
export const registerRequest = loginRequest.omit({ grant_type: true }).extend({
|
||||||
email: z.string().email(),
|
is_active: z.boolean().optional(),
|
||||||
password: z.string().min(1),
|
is_superuser: z.boolean().optional(),
|
||||||
is_active: z.boolean().optional(),
|
is_verified: z.boolean().optional(),
|
||||||
is_superuser: z.boolean().optional(),
|
|
||||||
is_verified: z.boolean().optional(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const registerResponse = z.object({
|
export const registerResponse = registerRequest
|
||||||
id: z.number(),
|
.omit({ password: true })
|
||||||
email: z.string().email(),
|
.extend({
|
||||||
is_active: z.boolean(),
|
id: z.number(),
|
||||||
is_superuser: z.boolean(),
|
pages_limit: z.number(),
|
||||||
is_verified: z.boolean(),
|
pages_used: z.number(),
|
||||||
pages_limit: z.number(),
|
});
|
||||||
pages_used: z.number(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type LoginRequest = z.infer<typeof loginRequest>;
|
export type LoginRequest = z.infer<typeof loginRequest>;
|
||||||
export type LoginResponse = z.infer<typeof loginResponse>;
|
export type LoginResponse = z.infer<typeof loginResponse>;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue