Make auth module optional to conditionnaly load auth providers (#518)

* Make auth module optional to conditionnaly load auth providers

* Fixes
This commit is contained in:
Charles Bochet
2023-07-05 15:46:09 +02:00
committed by GitHub
parent 463994df1f
commit 9ea765fcfd
6 changed files with 31 additions and 35 deletions

View File

@ -0,0 +1,18 @@
import { Transform } from 'class-transformer';
export function CastToBoolean() {
return Transform(({ value }: { value: string }) => toBoolean(value));
}
const toBoolean = (value: any) => {
if (typeof value === 'boolean') {
return value;
}
if (['true', 'on', 'yes', '1'].includes(value.toLowerCase())) {
return true;
}
if (['false', 'off', 'no', '0'].includes(value.toLowerCase())) {
return false;
}
return undefined;
};