Formatting.

This commit is contained in:
mike12345567 2021-04-26 14:16:05 +01:00
parent 84e66f826b
commit 5de2b26335
5 changed files with 76 additions and 53 deletions

View File

@ -30,7 +30,7 @@ exports.save = async function(ctx) {
switch (type) { switch (type) {
case Configs.SMTP: case Configs.SMTP:
await email.verifyConfig(config) await email.verifyConfig(config)
break; break
} }
try { try {

View File

@ -13,5 +13,5 @@ exports.routes = [
authRoutes, authRoutes,
appRoutes, appRoutes,
templateRoutes, templateRoutes,
emailRoutes emailRoutes,
] ]

View File

@ -39,14 +39,18 @@ class TestConfiguration {
async init() { async init() {
// create a test user // create a test user
await this._req({ await this._req(
{
email: "test@test.com", email: "test@test.com",
password: "test", password: "test",
_id: "us_uuid1", _id: "us_uuid1",
builder: { builder: {
global: true, global: true,
} },
}, null, controllers.users.save) },
null,
controllers.users.save
)
} }
defaultHeaders() { defaultHeaders() {
@ -57,54 +61,69 @@ class TestConfiguration {
const authToken = jwt.sign(user, env.JWT_SECRET) const authToken = jwt.sign(user, env.JWT_SECRET)
return { return {
Accept: "application/json", Accept: "application/json",
Cookie: [ Cookie: [`${Cookies.Auth}=${authToken}`],
`${Cookies.Auth}=${authToken}`,
],
} }
} }
async deleteConfig(type) { async deleteConfig(type) {
try { try {
const cfg = await this._req(null,{ const cfg = await this._req(
null,
{
type, type,
}, controllers.config.find) },
controllers.config.find
)
if (cfg) { if (cfg) {
await this._req(null, { await this._req(
null,
{
id: cfg._id, id: cfg._id,
rev: cfg._rev, rev: cfg._rev,
}, controllers.config.destroy) },
controllers.config.destroy
)
} }
} catch (err) {} } catch (err) {}
} }
async saveSettingsConfig() { async saveSettingsConfig() {
await this.deleteConfig(Configs.SETTINGS) await this.deleteConfig(Configs.SETTINGS)
await this._req({ await this._req(
{
type: Configs.SETTINGS, type: Configs.SETTINGS,
config: { config: {
platformUrl: "http://localhost:10000", platformUrl: "http://localhost:10000",
logoUrl: LOGO_URL, logoUrl: LOGO_URL,
company: "Budibase", company: "Budibase",
} },
}, null, controllers.config.save) },
null,
controllers.config.save
)
} }
async saveSmtpConfig() { async saveSmtpConfig() {
await this.deleteConfig(Configs.SMTP) await this.deleteConfig(Configs.SMTP)
await this._req({ await this._req(
{
type: Configs.SMTP, type: Configs.SMTP,
config: { config: {
port: 12345, port: 12345,
host: "smtptesthost.com", host: "smtptesthost.com",
from: "testfrom@test.com", from: "testfrom@test.com",
subject: "Hello!", subject: "Hello!",
} },
}, null, controllers.config.save) },
null,
controllers.config.save
)
} }
async saveEtherealSmtpConfig() { async saveEtherealSmtpConfig() {
await this.deleteConfig(Configs.SMTP) await this.deleteConfig(Configs.SMTP)
await this._req({ await this._req(
{
type: Configs.SMTP, type: Configs.SMTP,
config: { config: {
port: 587, port: 587,
@ -114,8 +133,11 @@ class TestConfiguration {
user: "don.bahringer@ethereal.email", user: "don.bahringer@ethereal.email",
pass: "yCKSH8rWyUPbnhGYk9", pass: "yCKSH8rWyUPbnhGYk9",
}, },
} },
}, null, controllers.config.save) },
null,
controllers.config.save
)
} }
} }

View File

@ -17,10 +17,10 @@ exports.EmailTemplates = {
join(__dirname, "invitation.hbs") join(__dirname, "invitation.hbs")
), ),
[EmailTemplatePurpose.BASE]: readStaticFile(join(__dirname, "base.hbs")), [EmailTemplatePurpose.BASE]: readStaticFile(join(__dirname, "base.hbs")),
[EmailTemplatePurpose.STYLES]: readStaticFile( [EmailTemplatePurpose.STYLES]: readStaticFile(join(__dirname, "style.hbs")),
join(__dirname, "style.hbs") [EmailTemplatePurpose.WELCOME]: readStaticFile(
join(__dirname, "welcome.hbs")
), ),
[EmailTemplatePurpose.WELCOME]: readStaticFile(join(__dirname, "welcome.hbs")),
} }
exports.addBaseTemplates = (templates, type = null) => { exports.addBaseTemplates = (templates, type = null) => {

View File

@ -28,7 +28,8 @@ exports.getSettingsTemplateContext = async () => {
), ),
[TemplateBindings.RESET_URL]: checkSlashesInUrl(`${URL}/reset`), [TemplateBindings.RESET_URL]: checkSlashesInUrl(`${URL}/reset`),
[TemplateBindings.COMPANY]: settings.company || BASE_COMPANY, [TemplateBindings.COMPANY]: settings.company || BASE_COMPANY,
[TemplateBindings.DOCS_URL]: settings.docsUrl || "https://docs.budibase.com/", [TemplateBindings.DOCS_URL]:
settings.docsUrl || "https://docs.budibase.com/",
[TemplateBindings.LOGIN_URL]: checkSlashesInUrl(`${URL}/login`), [TemplateBindings.LOGIN_URL]: checkSlashesInUrl(`${URL}/login`),
} }
} }