mirror of
https://github.com/unraid/api.git
synced 2026-01-06 00:30:22 -06:00
feat: implement OIDC provider management in GraphQL API (#1563)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
"@types/lodash-es": "4.17.12",
|
||||
"@types/node": "22.17.1",
|
||||
"@types/ws": "^8.5.13",
|
||||
"class-transformer": "0.5.1",
|
||||
"class-validator": "0.14.2",
|
||||
"graphql": "16.11.0",
|
||||
"graphql-scalars": "1.24.2",
|
||||
|
||||
@@ -19,7 +19,7 @@ export interface SettingsFragment<T> {
|
||||
getCurrentValues(): Promise<T>;
|
||||
updateValues(
|
||||
values: Partial<T>
|
||||
): Promise<{ restartRequired?: boolean; values: Partial<T> }>;
|
||||
): Promise<{ restartRequired?: boolean; values: Partial<T>; warnings?: string[] }>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,16 +117,17 @@ export class UserSettingsService {
|
||||
async updateValues<T extends keyof UserSettings>(
|
||||
name: T,
|
||||
values: Partial<UserSettings[T]>
|
||||
): Promise<{ restartRequired?: boolean; values: Partial<UserSettings[T]> }> {
|
||||
): Promise<{ restartRequired?: boolean; values: Partial<UserSettings[T]>; warnings?: string[] }> {
|
||||
const fragment = this.getOrThrow(name);
|
||||
return fragment.updateValues(values);
|
||||
}
|
||||
|
||||
/** Update values from a namespaced object. */
|
||||
async updateNamespacedValues(
|
||||
values: Record<string, any>
|
||||
): Promise<{ restartRequired: boolean; values: Record<string, any> }> {
|
||||
values: Record<string, unknown>
|
||||
): Promise<{ restartRequired: boolean; values: Record<string, unknown>; warnings?: string[] }> {
|
||||
let restartRequired = false;
|
||||
let allWarnings: string[] = [];
|
||||
|
||||
for (const [key, fragmentValues] of Object.entries(values)) {
|
||||
if (!this.settings.has(key as keyof UserSettings)) {
|
||||
@@ -136,14 +137,26 @@ export class UserSettingsService {
|
||||
|
||||
const result = await this.updateValues(
|
||||
key as keyof UserSettings,
|
||||
fragmentValues
|
||||
fragmentValues as Partial<UserSettings[keyof UserSettings]>
|
||||
);
|
||||
if (result.restartRequired) {
|
||||
restartRequired = true;
|
||||
}
|
||||
// Collect any warnings from individual fragments
|
||||
if (result.warnings) {
|
||||
allWarnings = allWarnings.concat(result.warnings);
|
||||
}
|
||||
}
|
||||
|
||||
return { restartRequired, values: await this.getAllValues() };
|
||||
const response: { restartRequired: boolean; values: Record<string, unknown>; warnings?: string[] } = {
|
||||
restartRequired,
|
||||
values: await this.getAllValues()
|
||||
};
|
||||
if (allWarnings.length > 0) {
|
||||
response.warnings = allWarnings;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user