mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: update
This commit is contained in:
@@ -72,7 +72,7 @@ inserted_accounts AS (
|
|||||||
SELECT
|
SELECT
|
||||||
gen_random_uuid(),
|
gen_random_uuid(),
|
||||||
gen_random_uuid(),
|
gen_random_uuid(),
|
||||||
'credentials',
|
'credential',
|
||||||
a."adminId",
|
a."adminId",
|
||||||
auth.password,
|
auth.password,
|
||||||
COALESCE(auth."is2FAEnabled", false),
|
COALESCE(auth."is2FAEnabled", false),
|
||||||
@@ -166,7 +166,7 @@ inserted_member_accounts AS (
|
|||||||
SELECT
|
SELECT
|
||||||
gen_random_uuid(),
|
gen_random_uuid(),
|
||||||
gen_random_uuid(),
|
gen_random_uuid(),
|
||||||
'credentials',
|
'credential',
|
||||||
u."userId",
|
u."userId",
|
||||||
auth.password,
|
auth.password,
|
||||||
COALESCE(auth."is2FAEnabled", false),
|
COALESCE(auth."is2FAEnabled", false),
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ await db
|
|||||||
.then((user) => user[0]);
|
.then((user) => user[0]);
|
||||||
|
|
||||||
await db.insert(schema.account).values({
|
await db.insert(schema.account).values({
|
||||||
providerId: "credentials",
|
providerId: "credential",
|
||||||
userId: user?.id || "",
|
userId: user?.id || "",
|
||||||
password: admin.auth.password,
|
password: admin.auth.password,
|
||||||
is2FAEnabled: admin.auth.is2FAEnabled || false,
|
is2FAEnabled: admin.auth.is2FAEnabled || false,
|
||||||
@@ -101,7 +101,7 @@ await db
|
|||||||
.then((userTemp) => userTemp[0]);
|
.then((userTemp) => userTemp[0]);
|
||||||
|
|
||||||
await db.insert(schema.account).values({
|
await db.insert(schema.account).values({
|
||||||
providerId: "credentials",
|
providerId: "credential",
|
||||||
userId: member?.userId || "",
|
userId: member?.userId || "",
|
||||||
password: member.auth.password,
|
password: member.auth.password,
|
||||||
is2FAEnabled: member.auth.is2FAEnabled || false,
|
is2FAEnabled: member.auth.is2FAEnabled || false,
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ export default function Home({ IS_CLOUD }: Props) {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const form = useForm<Login>({
|
const form = useForm<Login>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
email: "user5@yopmail.com",
|
email: "",
|
||||||
password: "Password1234",
|
password: "",
|
||||||
},
|
},
|
||||||
resolver: zodResolver(loginSchema),
|
resolver: zodResolver(loginSchema),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const lucia = new Lucia(adapter, {
|
|||||||
secure: false,
|
secure: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
sessionExpiresIn: new TimeSpan(1, "d"),
|
sessionExpiresIn: new TimeSpan(1, "d"),
|
||||||
getUserAttributes: (attributes) => {
|
getUserAttributes: (attributes) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,23 +1,28 @@
|
|||||||
import type { IncomingMessage } from "node:http";
|
import type { IncomingMessage } from "node:http";
|
||||||
|
import * as bcrypt from "bcrypt";
|
||||||
import { betterAuth } from "better-auth";
|
import { betterAuth } from "better-auth";
|
||||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||||
import { admin, createAuthMiddleware, organization } from "better-auth/plugins";
|
import { createAuthMiddleware, organization } from "better-auth/plugins";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { db } from "../db";
|
import { db } from "../db";
|
||||||
import * as schema from "../db/schema";
|
import * as schema from "../db/schema";
|
||||||
import { Scrypt } from "lucia";
|
|
||||||
const scrypt = new Scrypt();
|
|
||||||
|
|
||||||
export const auth = betterAuth({
|
export const auth = betterAuth({
|
||||||
database: drizzleAdapter(db, {
|
database: drizzleAdapter(db, {
|
||||||
provider: "pg",
|
provider: "pg",
|
||||||
schema: schema,
|
schema: schema,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
emailAndPassword: {
|
emailAndPassword: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
||||||
password: {
|
password: {
|
||||||
hash: scrypt.hash,
|
async hash(password) {
|
||||||
verify: scrypt.verify,
|
return bcrypt.hashSync(password, 10);
|
||||||
|
},
|
||||||
|
async verify({ hash, password }) {
|
||||||
|
return bcrypt.compareSync(password, hash);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
hooks: {
|
hooks: {
|
||||||
@@ -35,7 +40,6 @@ export const auth = betterAuth({
|
|||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
modelName: "users_temp",
|
modelName: "users_temp",
|
||||||
additionalFields: {},
|
|
||||||
},
|
},
|
||||||
plugins: [organization()],
|
plugins: [organization()],
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user