mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: add 2fa
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import {
|
||||
boolean,
|
||||
integer,
|
||||
pgTable,
|
||||
text,
|
||||
integer,
|
||||
timestamp,
|
||||
boolean,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
export const users_temp = pgTable("users_temp", {
|
||||
|
||||
@@ -16,7 +16,16 @@ export const auth = betterAuth({
|
||||
provider: "pg",
|
||||
schema: schema,
|
||||
}),
|
||||
|
||||
socialProviders: {
|
||||
github: {
|
||||
clientId: process.env.GITHUB_CLIENT_ID as string,
|
||||
clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
|
||||
},
|
||||
google: {
|
||||
clientId: process.env.GOOGLE_CLIENT_ID as string,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
|
||||
},
|
||||
},
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
|
||||
|
||||
@@ -106,26 +106,25 @@ export const isAdminPresent = async () => {
|
||||
};
|
||||
|
||||
export const getUserByToken = async (token: string) => {
|
||||
// const user = await db.query.users.findFirst({
|
||||
// where: eq(users.token, token),
|
||||
// with: {
|
||||
// auth: {
|
||||
// columns: {
|
||||
// password: false,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// if (!user) {
|
||||
// throw new TRPCError({
|
||||
// code: "NOT_FOUND",
|
||||
// message: "Invitation not found",
|
||||
// });
|
||||
// }
|
||||
// return {
|
||||
// ...user,
|
||||
// isExpired: user.isRegistered,
|
||||
// };
|
||||
const user = await db.query.users_temp.findFirst({
|
||||
where: eq(users_temp.token, token),
|
||||
columns: {
|
||||
id: true,
|
||||
email: true,
|
||||
token: true,
|
||||
isRegistered: true,
|
||||
},
|
||||
});
|
||||
if (!user) {
|
||||
throw new TRPCError({
|
||||
code: "NOT_FOUND",
|
||||
message: "Invitation not found",
|
||||
});
|
||||
}
|
||||
return {
|
||||
...user,
|
||||
isExpired: user.isRegistered,
|
||||
};
|
||||
};
|
||||
|
||||
export const removeUserById = async (userId: string) => {
|
||||
|
||||
@@ -29,16 +29,15 @@ class LogRotationManager {
|
||||
}
|
||||
|
||||
private async getStateFromDB(): Promise<boolean> {
|
||||
const setting = await db.query.admins.findFirst({});
|
||||
return setting?.enableLogRotation ?? false;
|
||||
// const setting = await db.query.admins.findFirst({});
|
||||
// return setting?.enableLogRotation ?? false;
|
||||
}
|
||||
|
||||
private async setStateInDB(active: boolean): Promise<void> {
|
||||
const admin = await db.query.admins.findFirst({});
|
||||
|
||||
if (!admin) {
|
||||
return;
|
||||
}
|
||||
// const admin = await db.query.admins.findFirst({});
|
||||
// if (!admin) {
|
||||
// return;
|
||||
// }
|
||||
// await updateAdmin(admin?.authId, {
|
||||
// enableLogRotation: active,
|
||||
// });
|
||||
|
||||
Reference in New Issue
Block a user