mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-05 02:24:59 +02:00
make config class and separate migrations script
This commit is contained in:
parent
b199595100
commit
9732098799
45 changed files with 163 additions and 156 deletions
|
@ -99,7 +99,7 @@ export async function disable2fa(
|
|||
}),
|
||||
{
|
||||
to: user.email,
|
||||
from: config.email?.no_reply,
|
||||
from: config.getRawConfig().email?.no_reply,
|
||||
subject: "Two-factor authentication disabled"
|
||||
}
|
||||
);
|
||||
|
|
|
@ -127,7 +127,7 @@ export async function login(
|
|||
|
||||
if (
|
||||
!existingUser.emailVerified &&
|
||||
config.flags?.require_email_verification
|
||||
config.getRawConfig().flags?.require_email_verification
|
||||
) {
|
||||
return response<LoginResponse>(res, {
|
||||
data: { emailVerificationRequired: true },
|
||||
|
|
|
@ -16,7 +16,7 @@ export async function requestEmailVerificationCode(
|
|||
res: Response,
|
||||
next: NextFunction
|
||||
): Promise<any> {
|
||||
if (!config.flags?.require_email_verification) {
|
||||
if (!config.getRawConfig().flags?.require_email_verification) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.BAD_REQUEST,
|
||||
|
|
|
@ -82,7 +82,7 @@ export async function requestPasswordReset(
|
|||
});
|
||||
});
|
||||
|
||||
const url = `${config.app.base_url}/auth/reset-password?email=${email}&token=${token}`;
|
||||
const url = `${config.getRawConfig().app.base_url}/auth/reset-password?email=${email}&token=${token}`;
|
||||
|
||||
await sendEmail(
|
||||
ResetPasswordCode({
|
||||
|
@ -91,7 +91,7 @@ export async function requestPasswordReset(
|
|||
link: url
|
||||
}),
|
||||
{
|
||||
from: config.email?.no_reply,
|
||||
from: config.getRawConfig().email?.no_reply,
|
||||
to: email,
|
||||
subject: "Reset your password"
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ export async function resetPassword(
|
|||
});
|
||||
|
||||
await sendEmail(ConfirmPasswordReset({ email }), {
|
||||
from: config.email?.no_reply,
|
||||
from: config.getRawConfig().email?.no_reply,
|
||||
to: email,
|
||||
subject: "Password Reset Confirmation"
|
||||
});
|
||||
|
|
|
@ -60,7 +60,7 @@ export async function signup(
|
|||
const passwordHash = await hashPassword(password);
|
||||
const userId = generateId(15);
|
||||
|
||||
if (config.flags?.disable_signup_without_invite) {
|
||||
if (config.getRawConfig().flags?.disable_signup_without_invite) {
|
||||
if (!inviteToken || !inviteId) {
|
||||
return next(
|
||||
createHttpError(
|
||||
|
@ -102,7 +102,7 @@ export async function signup(
|
|||
.where(eq(users.email, email));
|
||||
|
||||
if (existing && existing.length > 0) {
|
||||
if (!config.flags?.require_email_verification) {
|
||||
if (!config.getRawConfig().flags?.require_email_verification) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.BAD_REQUEST,
|
||||
|
@ -163,7 +163,7 @@ export async function signup(
|
|||
const cookie = serializeSessionCookie(token);
|
||||
res.appendHeader("Set-Cookie", cookie);
|
||||
|
||||
if (config.flags?.require_email_verification) {
|
||||
if (config.getRawConfig().flags?.require_email_verification) {
|
||||
sendEmailVerificationCode(email, userId);
|
||||
|
||||
return response<SignUpResponse>(res, {
|
||||
|
|
|
@ -28,7 +28,7 @@ export async function verifyEmail(
|
|||
res: Response,
|
||||
next: NextFunction
|
||||
): Promise<any> {
|
||||
if (!config.flags?.require_email_verification) {
|
||||
if (!config.getRawConfig().flags?.require_email_verification) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.BAD_REQUEST,
|
||||
|
|
|
@ -111,7 +111,7 @@ export async function verifyTotp(
|
|||
}),
|
||||
{
|
||||
to: user.email,
|
||||
from: config.email?.no_reply,
|
||||
from: config.getRawConfig().email?.no_reply,
|
||||
subject: "Two-factor authentication enabled"
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue