Compare commits

..

3 Commits

2 changed files with 32 additions and 28 deletions

View File

@@ -46,35 +46,32 @@ passport.use(new OpenIDConnectStrategy({
//lookup existing user //lookup existing user
const existing = await con.query(`SELECT id FROM members WHERE authentik_issuer = ? AND authentik_sub = ? LIMIT 1;`, [issuer, sub]); const existing = await con.query(`SELECT id FROM members WHERE authentik_issuer = ? AND authentik_sub = ? LIMIT 1;`, [issuer, sub]);
let memberId: number | null = null; let memberId: number;
//if member exists //if member exists
if (existing.length > 0) { if (existing.length > 0) {
memberId = existing[0].id; memberId = existing[0].id;
} else { } else {
//otherwise: create account mode //otherwise: create account
const jwt = parseJwt(jwtClaims); const jwt = parseJwt(jwtClaims);
const discordID = jwt.discord?.id as number; const discordID = jwt.discord.id as number;
//check if account is available to claim //check if account is available to claim
if (discordID) memberId = await mapDiscordtoID(discordID);
memberId = await mapDiscordtoID(discordID);
if (discordID && memberId) { if (memberId === null) {
// claim account // create new account
console.log("Claiming account");
const result = await con.query(
`UPDATE members SET authentik_sub = ?, authentik_issuer = ? WHERE id = ?;`,
[sub, issuer, memberId]
)
} else {
console.log("New Account");
// new account
const username = sub.username; const username = sub.username;
const result = await con.query( const result = await con.query(
`INSERT INTO members (name, authentik_sub, authentik_issuer) VALUES (?, ?, ?)`, `INSERT INTO members (name, authentik_sub, authentik_issuer) VALUES (?, ?, ?)`,
[username, sub, issuer] [username, sub, issuer]
) )
memberId = Number(result.insertId); memberId = Number(result.insertId);
} else {
// claim existing account
const result = await con.query(
`UPDATE members SET authentik_sub = ?, authentik_issuer = ? WHERE id = ?;`,
[sub, issuer, memberId]
)
} }
} }

View File

@@ -84,7 +84,7 @@ function loaStatus(loa: LOARequest): "Upcoming" | "Active" | "Overdue" | "Closed
if (now < start) return "Upcoming"; if (now < start) return "Upcoming";
if (now >= start && now <= end) return "Active"; if (now >= start && now <= end) return "Active";
if (now > end) return "Overdue"; if (now > loa.extended_till || end) return "Overdue";
return "Overdue"; // fallback return "Overdue"; // fallback
} }
@@ -197,7 +197,7 @@ function setPage(pagenum: number) {
<TableCell @click.stop="" class="text-right"> <TableCell @click.stop="" class="text-right">
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger class="cursor-pointer"> <DropdownMenuTrigger class="cursor-pointer">
<Button variant="ghost"> <Button variant="ghost" size="icon">
<Ellipsis class="size-6"></Ellipsis> <Ellipsis class="size-6"></Ellipsis>
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
@@ -220,10 +220,11 @@ function setPage(pagenum: number) {
</DropdownMenu> </DropdownMenu>
</TableCell> </TableCell>
<TableCell> <TableCell>
<Button v-if="expanded === post.id" @click.stop="expanded = null" variant="ghost"> <Button v-if="expanded === post.id" @click.stop="expanded = null" size="icon"
variant="ghost">
<ChevronUp class="size-6" /> <ChevronUp class="size-6" />
</Button> </Button>
<Button v-else @click.stop="expanded = post.id" variant="ghost"> <Button v-else @click.stop="expanded = post.id" size="icon" variant="ghost">
<ChevronDown class="size-6" /> <ChevronDown class="size-6" />
</Button> </Button>
</TableCell> </TableCell>
@@ -233,18 +234,24 @@ function setPage(pagenum: number) {
<TableCell :colspan="8" class="p-0"> <TableCell :colspan="8" class="p-0">
<div class="w-full p-3 mb-6 space-y-3"> <div class="w-full p-3 mb-6 space-y-3">
<div class="flex justify-between items-start gap-4"> <div class="flex justify-between items-start gap-4">
<div class="flex-1"> <div class="space-y-3 w-full">
<!-- Title -->
<p class="text-md font-semibold text-foreground"> <!-- Header -->
Reason <div class="flex items-center gap-2">
</p> <h4 class="text-sm font-semibold text-foreground">
Reason
</h4>
<Separator class="flex-1" />
</div>
<!-- Content --> <!-- Content -->
<p <div
class="mt-1 text-md whitespace-pre-wrap leading-relaxed text-muted-foreground"> class="rounded-lg border bg-muted/40 px-4 py-3 text-sm leading-relaxed whitespace-pre-wrap text-muted-foreground w-full">
{{ post.reason }} {{ post.reason || 'No reason provided.' }}
</p> </div>
</div> </div>
</div> </div>
</div> </div>
</TableCell> </TableCell>