feat: add email_verified claim

This commit is contained in:
Elias Schneider
2024-10-25 21:33:54 +02:00
parent bd4f87b2d2
commit 5565f60d6d
10 changed files with 64 additions and 29 deletions

View File

@@ -14,14 +14,19 @@ export default class AppConfigService extends APIService {
const appConfig: Partial<AllAppConfig> = {};
data.forEach(({ key, value }) => {
(appConfig as any)[key] = value;
(appConfig as any)[key] = this.parseValue(value);
});
return appConfig as AllAppConfig;
}
async update(appConfig: AllAppConfig) {
const res = await this.api.put('/application-configuration', appConfig);
// Convert all values to string
const appConfigConvertedToString = {};
for (const key in appConfig) {
(appConfigConvertedToString as any)[key] = (appConfig as any)[key].toString();
}
const res = await this.api.put('/application-configuration', appConfigConvertedToString);
return res.data as AllAppConfig;
}
@@ -62,4 +67,16 @@ export default class AppConfigService extends APIService {
currentVersion
};
}
private parseValue(value: string) {
if (value === 'true') {
return true;
} else if (value === 'false') {
return false;
} else if (!isNaN(Number(value))) {
return Number(value);
} else {
return value;
}
}
}

View File

@@ -1,16 +1,18 @@
export type AllAppConfig = {
export type AppConfig = {
appName: string;
sessionDuration: string;
emailEnabled: string;
};
export type AllAppConfig = AppConfig & {
sessionDuration: number;
emailsVerified: boolean;
emailEnabled: boolean;
smtpHost: string;
smtpPort: string;
smtpPort: number;
smtpFrom: string;
smtpUser: string;
smtpPassword: string;
};
export type AppConfig = AllAppConfig;
export type AppConfigRawResponse = {
key: string;
type: string;
@@ -21,4 +23,4 @@ export type AppVersionInformation = {
isUpToDate: boolean;
newestVersion: string;
currentVersion: string;
};
};

View File

@@ -1,5 +1,5 @@
export function debounced<T extends (...args: any[]) => void>(func: T, delay: number) {
let debounceTimeout: number | undefined;
let debounceTimeout: ReturnType<typeof setTimeout>;
return (...args: Parameters<T>) => {
if (debounceTimeout !== undefined) {
@@ -10,4 +10,4 @@ export function debounced<T extends (...args: any[]) => void>(func: T, delay: nu
func(...args);
}, delay);
};
}
}