Seed admin acccount and generalize login/auth routes

This commit is contained in:
Dominic Ferrando
2026-08-21 10:10:22 -04:00
parent 5432610090
commit 4dbcccdef7
8 changed files with 54 additions and 51 deletions
+11 -2
View File
@@ -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")