mirror of
https://github.com/zoriya/flood.git
synced 2026-06-02 02:56:05 +00:00
auth, Users: initial preparation for multi client support
BREAKING CHANGE
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import * as z from 'zod';
|
||||
|
||||
import {AccessLevel, credentialsSchema} from '../Auth';
|
||||
|
||||
// All auth requests are schema validated to ensure security.
|
||||
|
||||
// POST /api/auth/authenticate
|
||||
export const authAuthenticationSchema = credentialsSchema.pick({username: true, password: true});
|
||||
export type AuthAuthenticationOptions = Required<z.infer<typeof authAuthenticationSchema>>;
|
||||
|
||||
// POST /api/auth/authenticate - success response
|
||||
export interface AuthAuthenticationResponse {
|
||||
success: boolean;
|
||||
token: string;
|
||||
username: string;
|
||||
level: AccessLevel;
|
||||
}
|
||||
|
||||
// POST /api/auth/register
|
||||
export const authRegistrationSchema = credentialsSchema;
|
||||
export type AuthRegistrationOptions = Required<z.infer<typeof authRegistrationSchema>>;
|
||||
|
||||
// PATCH /api/auth/users/{username}
|
||||
export const authUpdateUserSchema = credentialsSchema.partial();
|
||||
export type AuthUpdateUserOptions = z.infer<typeof authUpdateUserSchema>;
|
||||
|
||||
// GET /api/auth/verify - success response
|
||||
export type AuthVerificationResponse =
|
||||
| {
|
||||
initialUser: true;
|
||||
}
|
||||
| {
|
||||
initialUser: false;
|
||||
username: string;
|
||||
level: AccessLevel;
|
||||
token?: string;
|
||||
};
|
||||
Reference in New Issue
Block a user