fix: created_by 注入 + 登出审计记录真实 username
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
6553b4c5c7
commit
5c1f2992b5
@ -223,10 +223,11 @@ export class AuthService {
|
||||
data: { revokedAt: new Date() },
|
||||
});
|
||||
await this.redis.del(this.permKey(record.tenantCode, record.userId));
|
||||
const user = await this.prisma.client.user.findUnique({ where: { id: record.userId } });
|
||||
await this.recordAudit({
|
||||
tenantCode: record.tenantCode,
|
||||
userId: record.userId,
|
||||
username: null,
|
||||
username: user?.username ?? null,
|
||||
module: 'auth',
|
||||
action: 'logout',
|
||||
status: 'success',
|
||||
|
||||
@ -53,7 +53,10 @@ export class BaseCrudService {
|
||||
|
||||
async create(data: Record<string, unknown>) {
|
||||
const ctx = getRequestContext();
|
||||
if (ctx && this.modelName !== 'tenant') data.tenantCode = ctx.tenantCode;
|
||||
if (ctx && this.modelName !== 'tenant') {
|
||||
data.tenantCode = ctx.tenantCode;
|
||||
data.createdBy = ctx.userId;
|
||||
}
|
||||
return this.db().create({ data });
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user