mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-19 23:53:17 -05:00
fix(admin): optional chain user in hooks (#8026)
(cherry picked from commit 62ed645354)
This commit is contained in:
@@ -86,9 +86,9 @@ export const admin = <O extends AdminOptions>(options?: O | undefined) => {
|
||||
}
|
||||
const user = (await ctx.context.internalAdapter.findUserById(
|
||||
session.userId,
|
||||
)) as UserWithRole;
|
||||
)) as UserWithRole | null;
|
||||
|
||||
if (user.banned) {
|
||||
if (user?.banned) {
|
||||
if (
|
||||
user.banExpires &&
|
||||
new Date(user.banExpires).getTime() < Date.now()
|
||||
|
||||
Reference in New Issue
Block a user