Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit 2d09183

Browse files
committed
feat: Add created_at and updated_at fields to User interfaces and update createUser method in UserRepository
1 parent 019fa00 commit 2d09183

File tree

7 files changed

+19
-5
lines changed

7 files changed

+19
-5
lines changed

dist/controllers/UserController.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ let Users = class Users {
7676
admin: !!user.admin,
7777
disabled: !!user.disabled,
7878
badges: user.badges || [],
79+
created_at: user.created_at, // <-- Ajout ici
7980
};
8081
}
8182
mapUserSearch(user) {
@@ -88,6 +89,7 @@ let Users = class Users {
8889
admin: !!user.admin,
8990
badges: user.badges || [],
9091
disabled: !!user.disabled,
92+
created_at: user.created_at, // <-- Ajout ici
9193
};
9294
}
9395
// --- AUTHENTIFICATION & INSCRIPTION ---

dist/interfaces/User.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface PublicUser {
99
admin?: boolean;
1010
badges: ('staff' | 'moderator' | 'community_manager' | 'early_user' | 'bug_hunter' | 'contributor' | 'partner')[];
1111
beta_user: boolean;
12+
created_at?: string;
13+
updated_at?: string;
1214
}
1315
export interface User extends PublicUser {
1416
email: string;
@@ -25,6 +27,8 @@ export interface User extends PublicUser {
2527
webauthn_challenge: string;
2628
webauthn_credentials?: string;
2729
authenticator_secret?: string;
30+
created_at: string;
31+
updated_at: string;
2832
}
2933
export interface PublicUserAsAdmin extends PublicUser {
3034
disabled?: boolean;

dist/repositories/UserRepository.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export declare class UserRepository {
1212
disableAccount(targetUserId: string): Promise<void>;
1313
reenableAccount(targetUserId: string): Promise<void>;
1414
searchUsers(): Promise<User[]>;
15-
createUser(user_id: string, username: string, email: string, password: string | null, provider?: "discord" | "google", providerId?: string): Promise<void>;
15+
createUser(user_id: string, username: string, email: string, password: string | null, provider?: "discord" | "google", providerId?: string, created_at?: string): Promise<void>;
1616
createBrandUser(user_id: string, username: string): Promise<void>;
1717
updateUserPassword(user_id: string, hashedPassword: string): Promise<void>;
1818
getUserBySteamId(steamId: string): Promise<User | null>;

dist/repositories/UserRepository.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ class UserRepository {
5757
async searchUsers() {
5858
return await this.databaseService.read(`SELECT user_id, username, verified, isStudio, admin, badges, beta_user, disabled FROM users LIMIT 100`);
5959
}
60-
async createUser(user_id, username, email, password, provider, providerId) {
61-
await this.databaseService.request("INSERT INTO users (user_id, username, email, password, balance, discord_id, google_id) VALUES (?, ?, ?, ?, 0, ?, ?)", [
60+
async createUser(user_id, username, email, password, provider, providerId, created_at) {
61+
await this.databaseService.request("INSERT INTO users (user_id, username, email, password, balance, discord_id, google_id, created_at) VALUES (?, ?, ?, ?, 0, ?, ?, ?)", [
6262
user_id,
6363
username,
6464
email,
6565
password,
6666
provider === "discord" ? providerId : null,
6767
provider === "google" ? providerId : null,
68+
created_at || new Date().toISOString().slice(0, 19).replace('T', ' '),
6869
]);
6970
}
7071
async createBrandUser(user_id, username) {

src/controllers/UserController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export class Users {
6767
admin: !!user.admin,
6868
disabled: !!user.disabled,
6969
badges: user.badges || [],
70+
created_at: user.created_at, // <-- Ajout ici
7071
};
7172
}
7273

@@ -80,6 +81,7 @@ export class Users {
8081
admin: !!user.admin,
8182
badges: user.badges || [],
8283
disabled: !!user.disabled,
84+
created_at: user.created_at, // <-- Ajout ici
8385
};
8486
}
8587

src/interfaces/User.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export interface PublicUser {
1010
admin?: boolean;
1111
badges: ('staff' | 'moderator' | 'community_manager' | 'early_user' | 'bug_hunter' | 'contributor' | 'partner')[];
1212
beta_user: boolean;
13+
created_at?: string;
14+
updated_at?: string;
1315
}
1416

1517
export interface User extends PublicUser {
@@ -27,6 +29,8 @@ export interface User extends PublicUser {
2729
webauthn_challenge: string;
2830
webauthn_credentials?: string;
2931
authenticator_secret?: string;
32+
created_at: string;
33+
updated_at: string;
3034
}
3135

3236
export interface PublicUserAsAdmin extends PublicUser {

src/repositories/UserRepository.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,17 @@ export class UserRepository {
8989
);
9090
}
9191

92-
async createUser(user_id: string, username: string, email: string, password: string | null, provider?: "discord" | "google", providerId?: string): Promise<void> {
92+
async createUser(user_id: string, username: string, email: string, password: string | null, provider?: "discord" | "google", providerId?: string, created_at?: string): Promise<void> {
9393
await this.databaseService.request(
94-
"INSERT INTO users (user_id, username, email, password, balance, discord_id, google_id) VALUES (?, ?, ?, ?, 0, ?, ?)",
94+
"INSERT INTO users (user_id, username, email, password, balance, discord_id, google_id, created_at) VALUES (?, ?, ?, ?, 0, ?, ?, ?)",
9595
[
9696
user_id,
9797
username,
9898
email,
9999
password,
100100
provider === "discord" ? providerId : null,
101101
provider === "google" ? providerId : null,
102+
created_at || new Date().toISOString().slice(0, 19).replace('T', ' '),
102103
]
103104
);
104105
}

0 commit comments

Comments
 (0)