Fix error handle
fix pagination issue change logic for change passsword and profile update
This commit is contained in:
@@ -77,43 +77,6 @@ export const auth = betterAuth({
|
||||
});
|
||||
},
|
||||
},
|
||||
update: {
|
||||
before: async (user, ctx) => {
|
||||
if (ctx?.context.session && ctx?.path === '/update-user') {
|
||||
const newUser = JSON.parse(JSON.stringify(user));
|
||||
const keys = Object.keys(newUser);
|
||||
const oldUser = Object.fromEntries(
|
||||
Object.entries(ctx?.context.session?.user).filter(([key]) =>
|
||||
keys.includes(key),
|
||||
),
|
||||
);
|
||||
await createAuditLog({
|
||||
action: LOG_ACTION.UPDATE,
|
||||
tableName: DB_TABLE.USER,
|
||||
recordId: ctx?.context.session?.user.id,
|
||||
oldValue: JSON.stringify(oldUser),
|
||||
newValue: JSON.stringify(newUser),
|
||||
userId: ctx?.context.session?.user.id,
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
account: {
|
||||
update: {
|
||||
after: async (account, context) => {
|
||||
if (context?.path === '/change-password') {
|
||||
await createAuditLog({
|
||||
action: LOG_ACTION.CHANGE_PASSWORD,
|
||||
tableName: DB_TABLE.ACCOUNT,
|
||||
recordId: account.id,
|
||||
oldValue: 'Change Password',
|
||||
newValue: 'Change Password',
|
||||
userId: account.userId,
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
session: {
|
||||
create: {
|
||||
|
||||
Reference in New Issue
Block a user