mirror of
https://github.com/kyantech/Palmr.git
synced 2025-11-02 04:53:26 +00:00
- Introduced OIDC authentication support with new OIDCService, controller, and routes for handling OIDC login and callback processes. - Updated user management functionalities to integrate OIDC, allowing users to authenticate via external providers. - Enhanced localization files to include new strings related to OIDC authentication across multiple languages. - Refactored existing components and hooks to support the new authentication flow, improving user experience during login and registration processes. - Added new UI components for handling OIDC login and callback, ensuring a seamless integration with the existing application structure.
81 lines
2.1 KiB
TypeScript
81 lines
2.1 KiB
TypeScript
import { prisma } from "../../shared/prisma";
|
|
import { ConfigService } from "../config/service";
|
|
|
|
export class AppService {
|
|
private configService = new ConfigService();
|
|
|
|
async getAppInfo() {
|
|
const [appName, appDescription, appLogo, firstUserAccess] = await Promise.all([
|
|
this.configService.getValue("appName"),
|
|
this.configService.getValue("appDescription"),
|
|
this.configService.getValue("appLogo"),
|
|
this.configService.getValue("firstUserAccess"),
|
|
]);
|
|
|
|
return {
|
|
appName,
|
|
appDescription,
|
|
appLogo,
|
|
firstUserAccess: firstUserAccess === "true",
|
|
};
|
|
}
|
|
|
|
async getAllConfigs() {
|
|
return prisma.appConfig.findMany({
|
|
where: {
|
|
key: {
|
|
not: "jwtSecret",
|
|
},
|
|
},
|
|
orderBy: {
|
|
group: "asc",
|
|
},
|
|
});
|
|
}
|
|
|
|
async updateConfig(key: string, value: string) {
|
|
if (key === "jwtSecret") {
|
|
throw new Error("JWT Secret cannot be updated through this endpoint");
|
|
}
|
|
|
|
const config = await prisma.appConfig.findUnique({
|
|
where: { key },
|
|
});
|
|
|
|
if (!config) {
|
|
throw new Error("Configuration not found");
|
|
}
|
|
|
|
return prisma.appConfig.update({
|
|
where: { key },
|
|
data: { value },
|
|
});
|
|
}
|
|
|
|
async bulkUpdateConfigs(updates: Array<{ key: string; value: string }>) {
|
|
if (updates.some((update) => update.key === "jwtSecret")) {
|
|
throw new Error("JWT Secret cannot be updated through this endpoint");
|
|
}
|
|
|
|
const keys = updates.map((update) => update.key);
|
|
const existingConfigs = await prisma.appConfig.findMany({
|
|
where: { key: { in: keys } },
|
|
});
|
|
|
|
if (existingConfigs.length !== keys.length) {
|
|
const existingKeys = existingConfigs.map((config) => config.key);
|
|
const missingKeys = keys.filter((key) => !existingKeys.includes(key));
|
|
throw new Error(`Configurations not found: ${missingKeys.join(", ")}`);
|
|
}
|
|
|
|
return prisma.$transaction(
|
|
updates.map((update) =>
|
|
prisma.appConfig.update({
|
|
where: { key: update.key },
|
|
data: { value: update.value },
|
|
})
|
|
)
|
|
);
|
|
}
|
|
}
|