add mail type and validation
This commit is contained in:
parent
2e3d0a755c
commit
ce9f621b8b
11 changed files with 193 additions and 19 deletions
|
@ -165,9 +165,9 @@ export async function getApplicationFavicon(req: Request, res: Response): Promis
|
|||
"Cross-Origin-Resource-Policy": "cross-origin",
|
||||
"Cross-Origin-Embedder-Policy": "credentialless",
|
||||
"Timing-Allow-Origin": "*",
|
||||
"Content-Type": "image/x-icon",
|
||||
});
|
||||
|
||||
res.setHeader("Content-Type", "image/x-icon");
|
||||
res.send(buffer);
|
||||
}
|
||||
|
||||
|
@ -178,8 +178,8 @@ export async function getApplicationFavicon(req: Request, res: Response): Promis
|
|||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getApplicationIcon(req: Request, res: Response): Promise<any> {
|
||||
const width = parseInt((req.query.width as string) ?? "");
|
||||
const height = parseInt((req.query.height as string) ?? "");
|
||||
const width = parseInt((req.query.width as string) ?? "512");
|
||||
const height = parseInt((req.query.height as string) ?? "512");
|
||||
|
||||
let icon = FileSystemHelper.readAssetFile("icon.png", true);
|
||||
let setLogo = SettingHelper.getSetting("club.icon");
|
||||
|
@ -200,8 +200,8 @@ export async function getApplicationIcon(req: Request, res: Response): Promise<a
|
|||
"Cross-Origin-Resource-Policy": "cross-origin",
|
||||
"Cross-Origin-Embedder-Policy": "credentialless",
|
||||
"Timing-Allow-Origin": "*",
|
||||
"Content-Type": "image/png",
|
||||
});
|
||||
|
||||
res.setHeader("Content-Type", "image/png");
|
||||
res.send(image);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { Request, Response } from "express";
|
||||
import SettingHelper from "../helpers/settingsHelper";
|
||||
import MailHelper from "../helpers/mailHelper";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
||||
/**
|
||||
* @description Service is currently not configured
|
||||
|
@ -88,7 +90,7 @@ export async function setAppIdentity(req: Request, res: Response): Promise<any>
|
|||
await SettingHelper.resetSetting("app.custom_login_message");
|
||||
}
|
||||
|
||||
if (show_link_to_calendar) {
|
||||
if (show_link_to_calendar == false || show_link_to_calendar == true) {
|
||||
await SettingHelper.setSetting("app.show_link_to_calendar", show_link_to_calendar);
|
||||
} else {
|
||||
await SettingHelper.resetSetting("app.show_link_to_calendar");
|
||||
|
@ -96,3 +98,45 @@ export async function setAppIdentity(req: Request, res: Response): Promise<any>
|
|||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description set app identity
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function setMailConfig(req: Request, res: Response): Promise<any> {
|
||||
const mail = req.body.mail;
|
||||
const username = req.body.username;
|
||||
const password = req.body.password;
|
||||
const host = req.body.host;
|
||||
const port = req.body.port;
|
||||
const secure = req.body.secure;
|
||||
|
||||
let checkMail = await MailHelper.checkMail(mail);
|
||||
|
||||
if (!checkMail) {
|
||||
throw new InternalException("Mail is not valid");
|
||||
}
|
||||
|
||||
let checkConfig = await MailHelper.verifyTransport({
|
||||
user: username,
|
||||
password,
|
||||
host,
|
||||
port,
|
||||
secure,
|
||||
});
|
||||
|
||||
if (!checkConfig) {
|
||||
throw new InternalException("Config is not valid");
|
||||
}
|
||||
|
||||
await SettingHelper.setSetting("mail.email", mail);
|
||||
await SettingHelper.setSetting("mail.username", username);
|
||||
await SettingHelper.setSetting("mail.password", password);
|
||||
await SettingHelper.setSetting("mail.host", host);
|
||||
await SettingHelper.setSetting("mail.port", port);
|
||||
await SettingHelper.setSetting("mail.secure", secure);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue