mirror of
https://github.com/nikdoof/pocket-id.git
synced 2025-12-22 13:59:24 +00:00
feat: add email_verified claim
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user