feat(server): support refresh token (#15218)

This commit is contained in:
DarkSky
2026-07-12 02:39:42 +08:00
committed by GitHub
parent aea128f0b9
commit 02b25e05d8
80 changed files with 5866 additions and 745 deletions
@@ -35,6 +35,7 @@ type UpdateConnectedAccountInput = Omit<
declare global {
interface Events {
'user.preDelete': { id: string };
'user.created': User;
'user.updated': User;
'user.deleted': User & {
@@ -60,6 +61,16 @@ export type { ConnectedAccount, User };
@Injectable()
export class UserModel extends BaseModel {
async lockForAuthIssuance(id: string) {
const users = await this.db.$queryRaw<Array<Pick<User, 'id' | 'disabled'>>>`
SELECT id, disabled
FROM users
WHERE id = ${id}
FOR UPDATE
`;
return users[0];
}
constructor(
private readonly crypto: CryptoHelper,
private readonly event: EventBus
@@ -284,6 +295,8 @@ export class UserModel extends BaseModel {
}
}
await this.event.emitAsync('user.preDelete', { id });
await this.db.workspaceInvitation.deleteMany({
where: { inviteeUserId: id },
});