allow tokens to limit a user's rank

This commit is contained in:
Hazelnoot 2025-06-21 09:46:31 -04:00
parent a4c816d07c
commit 70b85e5215
8 changed files with 72 additions and 4 deletions

View file

@ -8,6 +8,9 @@ import { id } from './util/id.js';
import { MiUser } from './User.js';
import { MiApp } from './App.js';
export const accessTokenRanks = ['user', 'mod', 'admin'] as const;
export type AccessTokenRank = typeof accessTokenRanks[number];
@Entity('access_token')
export class MiAccessToken {
@PrimaryColumn(id())
@ -87,4 +90,11 @@ export class MiAccessToken {
default: false,
})
public fetched: boolean;
@Column('enum', {
enum: accessTokenRanks,
nullable: true,
comment: 'Limits the user\' rank (user, moderator, or admin) when using this token. If null (default), then uses the user\'s actual rank.',
})
public rank: AccessTokenRank | null;
}