Seed admin acccount and generalize login/auth routes
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { Activity, Gender, type Player } from "@blade-and-brawn/domain";
|
||||
import { Activity, Gender } from "@blade-and-brawn/domain";
|
||||
import { db } from "../database/db";
|
||||
import type { CalculatorService } from "./calculator";
|
||||
import { Value } from "@sinclair/typebox/value";
|
||||
import { t } from "elysia";
|
||||
|
||||
export type AccountRole = "user" | "admin";
|
||||
|
||||
export class AccountsService {
|
||||
constructor(private Calculator: CalculatorService) { }
|
||||
|
||||
@@ -26,11 +28,18 @@ export class AccountsService {
|
||||
|
||||
async get(id: string) {
|
||||
return await (db).selectFrom("accounts")
|
||||
.select(["id", "discord_id", "name", "email", "gender"])
|
||||
.select(["id", "discord_id", "name", "email", "gender", "role"])
|
||||
.where(...AccountsService.idComparison(id))
|
||||
.executeTakeFirst();
|
||||
}
|
||||
|
||||
async getByEmail(email: string) {
|
||||
return await (db).selectFrom("accounts")
|
||||
.select(["id", "discord_id", "name", "email", "gender", "password_hash", "role"])
|
||||
.where("email", "=", email)
|
||||
.executeTakeFirst();
|
||||
}
|
||||
|
||||
async stats(id: string) {
|
||||
const latestAssessment = await db.selectFrom("accounts")
|
||||
.innerJoin("assessments", "assessments.account_id", "accounts.id")
|
||||
|
||||
Reference in New Issue
Block a user