Skip to content

Commit 61355ce

Browse files
committed
fix type-error
1 parent e421e35 commit 61355ce

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/auth.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,11 @@ export const auth = betterAuth({
116116
},
117117
hooks: {
118118
after: createAuthMiddleware(async (ctx) => {
119-
console.log(ctx.path, ctx.body);
119+
const userId = ctx.body?.userId as string | undefined;
120120
switch (ctx.path) {
121121
case '/admin/update-user':
122-
case '/admin/ban-user':
123122
case '/admin/unban-user':
124123
case '/admin/set-user-password':
125-
const { userId } = ctx.body as { userId?: string };
126124
if (userId) {
127125
const user = await User.findModel(userId);
128126
if (user) {
@@ -137,6 +135,21 @@ export const auth = betterAuth({
137135
}
138136
}
139137
break;
138+
case '/admin/ban-user':
139+
if (userId) {
140+
const user = await User.findModel(userId);
141+
if (user) {
142+
notify({
143+
to: [IoRoom.ADMIN],
144+
event: IoEvent.CHANGED_RECORD,
145+
message: {
146+
type: RecordType.User,
147+
record: user
148+
}
149+
});
150+
getIo().to(user.id).emit(IoEvent.ACTION, 'nav-reload');
151+
}
152+
}
140153
default:
141154
return;
142155
}

0 commit comments

Comments
 (0)