Created the password module
This commit is contained in:
35
modules/password/module.js
Normal file
35
modules/password/module.js
Normal file
@ -0,0 +1,35 @@
|
||||
const Joi = require("joi");
|
||||
const {getLinkById} = require("../../server/controller/link");
|
||||
|
||||
module.exports.onClick = async (id, accessId, metaData, controller, request) => {
|
||||
if (request?.body?.password === metaData.password)
|
||||
return controller.redirect(metaData.shortenUrl)
|
||||
|
||||
controller.locals.meta.title = (await getLinkById(id)).title;
|
||||
controller.render(__dirname + "/web/password");
|
||||
}
|
||||
|
||||
module.exports.info = {
|
||||
name: "Link mit Passwort",
|
||||
icon: "key",
|
||||
validationSchema: Joi.object({
|
||||
shortenUrl: Joi.string().max(2500).uri().required(),
|
||||
password: Joi.string().min(5).max(50).required()
|
||||
}),
|
||||
meta: [{
|
||||
name: "Link-Einstellungen",
|
||||
type: "default",
|
||||
fields: {
|
||||
shortenUrl: {
|
||||
type: "text",
|
||||
name: "Zu kürzende URL",
|
||||
description: "Die zu kürzende (lange) URL"
|
||||
},
|
||||
password: {
|
||||
type: "password",
|
||||
name: "Passwort",
|
||||
description: "Das gesicherte Passwort"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
Reference in New Issue
Block a user