generated from nhcarrigan/template
feat: security and auditing
This commit is contained in:
@@ -30,6 +30,29 @@ export class AuthService {
|
||||
return this.app.jwt.verify(token) as JwtPayload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by ID from database.
|
||||
*/
|
||||
async getUserById(id: string): Promise<User | null> {
|
||||
const dbUser = await this.prisma.user.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
|
||||
if (!dbUser) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
id: dbUser.id,
|
||||
discordId: dbUser.discordId,
|
||||
username: dbUser.username,
|
||||
email: dbUser.email,
|
||||
avatarUrl: dbUser.avatar || undefined,
|
||||
isAdmin: dbUser.isAdmin,
|
||||
isBanned: dbUser.isBanned,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or update user from Discord OAuth data.
|
||||
*/
|
||||
@@ -64,6 +87,7 @@ export class AuthService {
|
||||
email: dbUser.email,
|
||||
avatarUrl: dbUser.avatar || undefined,
|
||||
isAdmin: dbUser.isAdmin,
|
||||
isBanned: dbUser.isBanned,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user