added Create User

This commit is contained in:
2026-01-23 09:24:05 +07:00
parent a8745327d6
commit 51c26f3704
15 changed files with 500 additions and 46 deletions

View File

@@ -9,6 +9,7 @@ import {
} from '@/lib/auth/organization-permissions';
import { ac, admin, user } from '@/lib/auth/permissions';
import { createAuditLog } from '@/service/repository';
import { DB_TABLE, LOG_ACTION } from '@/types/enum';
import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';
import { admin as adminPlugin, organization } from 'better-auth/plugins';
@@ -66,6 +67,14 @@ export const auth = betterAuth({
color: '#000000',
},
});
await prisma.setting.create({
data: {
key: user.id,
value: '{"language": "en"}',
description: '',
relation: 'user',
},
});
},
},
update: {
@@ -79,8 +88,8 @@ export const auth = betterAuth({
),
);
await createAuditLog({
action: 'update',
tableName: 'user',
action: LOG_ACTION.UPDATE,
tableName: DB_TABLE.USER,
recordId: ctx?.context.session?.user.id,
oldValue: JSON.stringify(oldUser),
newValue: JSON.stringify(newUser),
@@ -95,8 +104,8 @@ export const auth = betterAuth({
after: async (account, context) => {
if (context?.path === '/change-password') {
await createAuditLog({
action: 'change_password',
tableName: 'account',
action: LOG_ACTION.CHANGE_PASSWORD,
tableName: DB_TABLE.ACCOUNT,
recordId: account.id,
oldValue: 'Change Password',
newValue: 'Change Password',
@@ -111,8 +120,8 @@ export const auth = betterAuth({
after: async (session, context) => {
if (context?.path.includes('/sign-in')) {
await createAuditLog({
action: 'sign_in',
tableName: 'session',
action: LOG_ACTION.SIGN_IN,
tableName: DB_TABLE.SESSION,
recordId: session.id,
oldValue: '',
newValue: JSON.stringify(session),
@@ -125,8 +134,8 @@ export const auth = betterAuth({
after: async (session, context) => {
if (context?.path === '/sign-out') {
await createAuditLog({
action: 'sign_out',
tableName: 'session',
action: LOG_ACTION.SIGN_OUT,
tableName: DB_TABLE.SESSION,
recordId: session.id,
oldValue: JSON.stringify(session),
newValue: '',