Skip to content

Commit c57aa4f

Browse files
committed
update
1 parent 35fb9c7 commit c57aa4f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/api/utils/authHandler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { eq } from "drizzle-orm";
22
import { DB } from "../../db";
33
import { randomBytes as crypto_randomBytes, createHash as crypto_createHash } from 'crypto';
44
import type { Context } from "hono";
5+
import type { UserAccountSettings } from "./shared-models/accountData";
56

67
export class AuthUtils {
78

@@ -132,7 +133,7 @@ export class SessionHandler {
132133
await DB.instance().delete(DB.Schema.sessions).where(eq(DB.Schema.sessions.id, tokenID));
133134
}
134135

135-
static async changeUserRoleInSessions(userID: number, newRole: "admin" | "user") {
136+
static async changeUserRoleInSessions(userID: number, newRole: UserAccountSettings.Role) {
136137
await DB.instance().update(DB.Schema.sessions).set({
137138
user_role: newRole
138139
}).where(
@@ -218,7 +219,7 @@ export class APIKeyHandler {
218219
await DB.instance().delete(DB.Schema.apiKeys).where(eq(DB.Schema.apiKeys.id, apiKeyID));
219220
}
220221

221-
static async changeUserRoleInApiKeys(userID: number, newRole: "admin" | "user") {
222+
static async changeUserRoleInApiKeys(userID: number, newRole: UserAccountSettings.Role) {
222223
await DB.instance().update(DB.Schema.apiKeys).set({
223224
user_role: newRole
224225
}).where(
@@ -301,7 +302,7 @@ export class AuthHandler {
301302
]).then(() => { return; });
302303
}
303304

304-
static async changeUserRoleInAuthContexts(userID: number, newRole: "admin" | "user"): Promise<void> {
305+
static async changeUserRoleInAuthContexts(userID: number, newRole: UserAccountSettings.Role): Promise<void> {
305306
return await Promise.all([
306307
SessionHandler.changeUserRoleInSessions(userID, newRole),
307308
APIKeyHandler.changeUserRoleInApiKeys(userID, newRole)

0 commit comments

Comments
 (0)