diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index c2fb2e16..65e18a8f 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -84,6 +84,7 @@ model Config { type String value String description String + obscured Boolean @default(false) secret Boolean @default(true) locked Boolean @default(false) } diff --git a/backend/prisma/seed/config.seed.ts b/backend/prisma/seed/config.seed.ts index 2a71df85..1ea2e153 100644 --- a/backend/prisma/seed/config.seed.ts +++ b/backend/prisma/seed/config.seed.ts @@ -1,7 +1,7 @@ -import { PrismaClient } from "@prisma/client"; +import { Prisma, PrismaClient } from "@prisma/client"; import * as crypto from "crypto"; -const configVariables = [ +const configVariables: Prisma.ConfigCreateInput[] = [ { key: "SETUP_FINISHED", description: "Whether the setup has been finished", @@ -83,6 +83,7 @@ const configVariables = [ description: "Password of the SMTP server", type: "string", value: "", + obscured: true, }, ]; diff --git a/backend/src/config/dto/adminConfig.dto.ts b/backend/src/config/dto/adminConfig.dto.ts index ab32c194..c358bc6f 100644 --- a/backend/src/config/dto/adminConfig.dto.ts +++ b/backend/src/config/dto/adminConfig.dto.ts @@ -11,6 +11,9 @@ export class AdminConfigDTO extends ConfigDTO { @Expose() description: string; + @Expose() + obscured: boolean; + from(partial: Partial) { return plainToClass(AdminConfigDTO, partial, { excludeExtraneousValues: true, diff --git a/frontend/src/components/admin/AdminConfigTable.tsx b/frontend/src/components/admin/AdminConfigTable.tsx index ac6a81c0..3ff883e1 100644 --- a/frontend/src/components/admin/AdminConfigTable.tsx +++ b/frontend/src/components/admin/AdminConfigTable.tsx @@ -54,17 +54,20 @@ const AdminConfigTable = () => { {isLoading ? skeletonRows - : configVariables.map((element) => ( - + : configVariables.map((configVariable) => ( + - {element.key} {element.secret && }{" "} -
+ {configVariable.key}{" "} + {configVariable.secret && }
- {element.description} + {configVariable.description} - {element.value} - + + {configVariable.obscured + ? "••••••••••••" + : configVariable.value} + { onClick={() => showUpdateConfigVariableModal( modals, - element, + configVariable, getConfigVariables ) } diff --git a/frontend/src/components/admin/showCreateUserModal.tsx b/frontend/src/components/admin/showCreateUserModal.tsx index f7732fd4..38a480c5 100644 --- a/frontend/src/components/admin/showCreateUserModal.tsx +++ b/frontend/src/components/admin/showCreateUserModal.tsx @@ -62,10 +62,7 @@ const Body = ({ > - + Set {configVariable.key} to - {configVariable.type == "string" && ( - - )} + {configVariable.type == "string" && + (configVariable.obscured ? ( + + ) : ( + + ))} {configVariable.type == "number" && ( )} diff --git a/frontend/src/components/admin/showUpdateUserModal.tsx b/frontend/src/components/admin/showUpdateUserModal.tsx index 7bda6db2..d87c84dd 100644 --- a/frontend/src/components/admin/showUpdateUserModal.tsx +++ b/frontend/src/components/admin/showUpdateUserModal.tsx @@ -79,10 +79,7 @@ const Body = ({ label="Username" {...accountForm.getInputProps("username")} /> - + { label="Username" {...accountForm.getInputProps("username")} /> - + diff --git a/frontend/src/types/config.type.ts b/frontend/src/types/config.type.ts index 6704218b..8f7d927f 100644 --- a/frontend/src/types/config.type.ts +++ b/frontend/src/types/config.type.ts @@ -8,6 +8,7 @@ export type AdminConfig = Config & { updatedAt: Date; secret: boolean; description: string; + obscured: boolean; }; export default Config;