mirror of
https://github.com/tale/headplane.git
synced 2026-08-20 01:42:17 +00:00
fix: if there are 0 admins, promote next admin on oidc login
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { createHash } from 'node:crypto';
|
import { createHash } from 'node:crypto';
|
||||||
import { count } from 'drizzle-orm';
|
import { count, eq } from 'drizzle-orm';
|
||||||
import { createCookie, type LoaderFunctionArgs, redirect } from 'react-router';
|
import { createCookie, type LoaderFunctionArgs, redirect } from 'react-router';
|
||||||
import { ulid } from 'ulidx';
|
import { ulid } from 'ulidx';
|
||||||
import type { LoadContext } from '~/server';
|
import type { LoadContext } from '~/server';
|
||||||
@@ -73,7 +73,8 @@ export async function loader({
|
|||||||
|
|
||||||
const [{ count: userCount }] = await context.db
|
const [{ count: userCount }] = await context.db
|
||||||
.select({ count: count() })
|
.select({ count: count() })
|
||||||
.from(users);
|
.from(users)
|
||||||
|
.where(eq(users.caps, Roles.owner));
|
||||||
|
|
||||||
await context.db
|
await context.db
|
||||||
.insert(users)
|
.insert(users)
|
||||||
|
|||||||
Reference in New Issue
Block a user