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"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
21
modules/password/web/password.ejs
Normal file
21
modules/password/web/password.ejs
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title><%= meta.title %></title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
<%- include('style.css'); %>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Passwort benötigt</h1>
|
||||
<form action="/<%= accessId %>" method="post" >
|
||||
<input type="password" name="password" class="form-control" placeholder="Passwort eingeben" />
|
||||
<button type="submit" class="btn btn-primary">Link öffnen</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
29
modules/password/web/style.css
Normal file
29
modules/password/web/style.css
Normal file
@ -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;
|
||||
}
|
Reference in New Issue
Block a user