mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
parent
5c428efa78
commit
6fadd4a420
4 changed files with 90 additions and 0 deletions
|
@ -5,6 +5,11 @@ export enum ApplicationType {
|
|||
SPA = 'SPA',
|
||||
Traditional = 'Traditional',
|
||||
}
|
||||
export enum PasscodeType {
|
||||
SignIn = 'SignIn',
|
||||
Register = 'Register',
|
||||
ForgotPassword = 'ForgotPassword',
|
||||
}
|
||||
export enum UserLogType {
|
||||
SignInUsernameAndPassword = 'SignInUsernameAndPassword',
|
||||
ExchangeAccessToken = 'ExchangeAccessToken',
|
||||
|
|
|
@ -4,6 +4,7 @@ export * from './custom-types';
|
|||
export * from './application';
|
||||
export * from './connector';
|
||||
export * from './oidc-model-instance';
|
||||
export * from './passcode';
|
||||
export * from './resource-scope';
|
||||
export * from './resource';
|
||||
export * from './setting';
|
||||
|
|
70
packages/schemas/src/db-entries/passcode.ts
Normal file
70
packages/schemas/src/db-entries/passcode.ts
Normal file
|
@ -0,0 +1,70 @@
|
|||
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
import { GeneratedSchema, Guard } from '../foundations';
|
||||
import { PasscodeType } from './custom-types';
|
||||
|
||||
export type CreatePasscode = {
|
||||
id: string;
|
||||
sessionId: string;
|
||||
phone?: string | null;
|
||||
email?: string | null;
|
||||
type: PasscodeType;
|
||||
code: string;
|
||||
consumed?: boolean;
|
||||
tryCount?: number;
|
||||
createdAt?: number;
|
||||
};
|
||||
|
||||
export type Passcode = {
|
||||
id: string;
|
||||
sessionId: string;
|
||||
phone: string | null;
|
||||
email: string | null;
|
||||
type: PasscodeType;
|
||||
code: string;
|
||||
consumed: boolean;
|
||||
tryCount: number;
|
||||
createdAt: number;
|
||||
};
|
||||
|
||||
const createGuard: Guard<CreatePasscode> = z.object({
|
||||
id: z.string(),
|
||||
sessionId: z.string(),
|
||||
phone: z.string().nullable().optional(),
|
||||
email: z.string().nullable().optional(),
|
||||
type: z.nativeEnum(PasscodeType),
|
||||
code: z.string(),
|
||||
consumed: z.boolean().optional(),
|
||||
tryCount: z.number().optional(),
|
||||
createdAt: z.number().optional(),
|
||||
});
|
||||
|
||||
export const Passcodes: GeneratedSchema<CreatePasscode> = Object.freeze({
|
||||
table: 'passcodes',
|
||||
tableSingular: 'passcode',
|
||||
fields: {
|
||||
id: 'id',
|
||||
sessionId: 'session_id',
|
||||
phone: 'phone',
|
||||
email: 'email',
|
||||
type: 'type',
|
||||
code: 'code',
|
||||
consumed: 'consumed',
|
||||
tryCount: 'try_count',
|
||||
createdAt: 'created_at',
|
||||
},
|
||||
fieldKeys: [
|
||||
'id',
|
||||
'sessionId',
|
||||
'phone',
|
||||
'email',
|
||||
'type',
|
||||
'code',
|
||||
'consumed',
|
||||
'tryCount',
|
||||
'createdAt',
|
||||
],
|
||||
createGuard,
|
||||
});
|
14
packages/schemas/tables/passcodes.sql
Normal file
14
packages/schemas/tables/passcodes.sql
Normal file
|
@ -0,0 +1,14 @@
|
|||
create type passcode_type as enum ('SignIn', 'Register', 'ForgotPassword');
|
||||
|
||||
create table passcodes (
|
||||
id varchar(128) not null,
|
||||
session_id varchar(128) not null,
|
||||
phone varchar(32),
|
||||
email varchar(128),
|
||||
type passcode_type not null,
|
||||
code varchar(6) not null,
|
||||
consumed boolean not null default FALSE,
|
||||
try_count int2 not null default 0,
|
||||
created_at timestamptz not null default(now()),
|
||||
primary key (id)
|
||||
);
|
Loading…
Add table
Reference in a new issue