-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backend - Ajoute les utilisateurs et les droits supports et vérifiés
- Loading branch information
1 parent
e356d7c
commit ee7563e
Showing
9 changed files
with
296 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { pgSchema } from 'drizzle-orm/pg-core'; | ||
import { timestamp, uuid, varchar } from 'drizzle-orm/pg-core/index'; | ||
|
||
export const authSchemaDB = pgSchema('auth'); | ||
|
||
export const authUsersTable = authSchemaDB.table('users', { | ||
id: uuid('user_id').primaryKey().notNull(), | ||
email: varchar('email', { length: 255 }), | ||
createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' }), | ||
lastSignInAt: timestamp('last_sign_in_at', { | ||
withTimezone: true, | ||
mode: 'string', | ||
}), | ||
|
||
/* | ||
TODO | ||
instance_id uuid, | ||
aud varchar(255), | ||
role varchar(255), | ||
encrypted_password varchar(255), | ||
email_confirmed_at timestamp with time zone, | ||
invited_at timestamp with time zone, | ||
confirmation_token varchar(255), | ||
confirmation_sent_at timestamp with time zone, | ||
recovery_token varchar(255), | ||
recovery_sent_at timestamp with time zone, | ||
email_change_token_new varchar(255), | ||
email_change varchar(255), | ||
email_change_sent_at timestamp with time zone, | ||
raw_app_meta_data jsonb, | ||
raw_user_meta_data jsonb, | ||
is_super_admin boolean, | ||
updated_at timestamp with time zone, | ||
phone text default NULL::character varying | ||
unique, | ||
phone_confirmed_at timestamp with time zone, | ||
phone_change text default ''::character varying, | ||
phone_change_token varchar(255) default ''::character varying, | ||
phone_change_sent_at timestamp with time zone, | ||
confirmed_at timestamp with time zone generated always as (LEAST(email_confirmed_at, phone_confirmed_at)) stored, | ||
email_change_token_current varchar(255) default ''::character varying, | ||
email_change_confirm_status smallint default 0 | ||
constraint users_email_change_confirm_status_check | ||
check ((email_change_confirm_status >= 0) AND (email_change_confirm_status <= 2)), | ||
banned_until timestamp with time zone, | ||
reauthentication_token varchar(255) default ''::character varying, | ||
reauthentication_sent_at timestamp with time zone, | ||
is_sso_user boolean default false not null, | ||
deleted_at timestamp with time zone, | ||
is_anonymous boolean default false not null | ||
*/ | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { boolean, pgTable, uuid, varchar } from 'drizzle-orm/pg-core/index'; | ||
import { text, timestamp } from 'drizzle-orm/pg-core'; | ||
|
||
export const dcpTable = pgTable('dcp', { | ||
userId: uuid('user_id').primaryKey().notNull(), // TODO .references(() => users.id), | ||
nom: text('nom').notNull(), | ||
prenom: text('prenom').notNull(), | ||
email: text('email').notNull(), | ||
limited: boolean('limited').default(false).notNull(), | ||
deleted: boolean('deleted').default(false).notNull(), | ||
createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' }) | ||
.defaultNow() | ||
.notNull(), | ||
modifiedAt: timestamp('modified_at', { withTimezone: true, mode: 'string' }) | ||
.defaultNow() | ||
.notNull(), | ||
telephone: varchar('telephone', { length: 30 }), | ||
cguAccepteesLe: timestamp('cgu_acceptees_le', { | ||
withTimezone: true, | ||
mode: 'string', | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as jwt from 'jsonwebtoken'; | ||
|
||
export enum SupabaseRole { | ||
AUTHENTICATED = 'authenticated', | ||
SERVICE_ROLE = 'service_role', | ||
ANON = 'anon', // Anonymous | ||
} | ||
export interface SupabaseJwtPayload extends jwt.JwtPayload { | ||
email?: string; | ||
phone?: string; | ||
app_metadata?: { | ||
provider: string; | ||
providers: string[]; | ||
}; | ||
session_id: string; | ||
role: SupabaseRole; | ||
is_anonymous: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { boolean, pgTable, uuid } from 'drizzle-orm/pg-core/index'; | ||
import { dcpTable } from './dcp.table'; | ||
|
||
export const utilisateurSupportTable = pgTable('utilisateur_support', { | ||
userId: uuid('user_id') | ||
.primaryKey() | ||
.notNull() | ||
.references(() => dcpTable.userId, { onDelete: 'cascade' }), | ||
support: boolean('support').default(false).notNull(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { boolean, pgTable, uuid } from 'drizzle-orm/pg-core/index'; | ||
import { dcpTable } from './dcp.table'; | ||
|
||
export const utilisateurVerifieTable = pgTable('utilisateur_verifie', { | ||
userId: uuid('user_id') | ||
.primaryKey() | ||
.notNull() | ||
.references(() => dcpTable.userId, { onDelete: 'cascade' }), | ||
verifie: boolean('verifie').default(false).notNull(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.