From 1414e1c1465ad940869535a8a3841444709288da Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sun, 8 Jan 2023 04:00:47 +0100 Subject: [PATCH] Created the password module --- modules/password/module.js | 35 +++++++++++++++++++++++++++++++ modules/password/web/password.ejs | 21 +++++++++++++++++++ modules/password/web/style.css | 29 +++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 modules/password/module.js create mode 100644 modules/password/web/password.ejs create mode 100644 modules/password/web/style.css diff --git a/modules/password/module.js b/modules/password/module.js new file mode 100644 index 0000000..94a94cb --- /dev/null +++ b/modules/password/module.js @@ -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" + } + } + }] +} diff --git a/modules/password/web/password.ejs b/modules/password/web/password.ejs new file mode 100644 index 0000000..10b970f --- /dev/null +++ b/modules/password/web/password.ejs @@ -0,0 +1,21 @@ + + + + <%= meta.title %> + + + + + + +
+

Passwort benötigt

+
+ + +
+
+ + diff --git a/modules/password/web/style.css b/modules/password/web/style.css new file mode 100644 index 0000000..85e11e5 --- /dev/null +++ b/modules/password/web/style.css @@ -0,0 +1,29 @@ +body { + background-color: #f1f1f1; + font-family: 'Courier New', serif; + min-height: 100vh; + display: flex; + align-items: center; +} + +.container { + max-width: 400px; + text-align: center; +} + +.form-control { + width: 300px; + margin: 20px auto; + padding: 15px; + box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1); + font-size: 1.2em; +} + +h1 { + margin-bottom: 30px; + font-size: 2em; +} + +button { + width: 300px; +}