From 86995cab676c0f1ff61d7dd73bfee5f2b21be370 Mon Sep 17 00:00:00 2001 From: Flummi Date: Tue, 20 Feb 2018 07:04:36 +0100 Subject: [PATCH] user --- public/css/user.css | 35 +++++++++++ src/fpaste.mjs | 1 + src/routes/index.mjs | 4 +- src/routes/r/index.mjs | 8 ++- src/routes/r/user.mjs | 14 +++++ views/layouts/main.handlebars | 111 +++++++++++++++++++++++++++++++++- views/login.handlebars | 7 +++ 7 files changed, 175 insertions(+), 5 deletions(-) create mode 100644 public/css/user.css create mode 100644 src/routes/r/user.mjs create mode 100644 views/login.handlebars diff --git a/public/css/user.css b/public/css/user.css new file mode 100644 index 0000000..46e9947 --- /dev/null +++ b/public/css/user.css @@ -0,0 +1,35 @@ +form p.label { + display: inline-block; + width: 150px; + margin-top: 5px; + margin-bottom: 5px; +} + +form p.checkbox { + display: inline-block; + margin-top: 5px; + margin-bottom: 5px; + margin-left: 5px; +} + +#settings-form input[type=submit], +#settings-form input[type=reset] { + margin: 20px 20px 5px 0; + display: inline-block; +} + +#user-activated-links a, +#logout-links a { + background-color: #777; + color: white; + border: 1px solid #666; + font-family: 'Ubuntu', sans-serif; + font-weight: bold; + padding: 10px; + margin: 5px 0 5px; + border-radius: 3px; + display: inline-block; + box-shadow: 3px 3px 10px #666; + cursor: pointer; + margin-right: 20px; +} \ No newline at end of file diff --git a/src/fpaste.mjs b/src/fpaste.mjs index 13c58fa..65c0dfe 100644 --- a/src/fpaste.mjs +++ b/src/fpaste.mjs @@ -23,6 +23,7 @@ app .use("/", router.index) .use("/v", router.view) .use("/a", router.about) + .use("/u", router.user) .get("/:uuid", (req, res) => res.redirect(`/v/${req.params.uuid}/`)) diff --git a/src/routes/index.mjs b/src/routes/index.mjs index d2e8e55..0e6f80c 100644 --- a/src/routes/index.mjs +++ b/src/routes/index.mjs @@ -1,10 +1,12 @@ import index from "./r/index"; import view from "./r/view"; import about from "./r/about"; +import user from "./r/user"; export default { index: index, view: view, - about: about + about: about, + user: user }; \ No newline at end of file diff --git a/src/routes/r/index.mjs b/src/routes/r/index.mjs index 3b35508..f908849 100644 --- a/src/routes/r/index.mjs +++ b/src/routes/r/index.mjs @@ -3,7 +3,7 @@ import express from "express"; import db from "../../lib/sql"; const queries = { - getlangs: "select * from `languages`", + getlangs: "select * from `languages` order by `name` asc", add: "insert into `pastes` (`uuid`,`lang`,`desc`,`paste`,`hidden`,`reply`) " + "values (LEFT(UUID(), 8), ?, ?, ?, ?, ?)", getuuid: "select `uuid` from `pastes` where `id` = ? limit 1" @@ -20,7 +20,7 @@ export default express.Router() desc: req.body.desc || "", content: req.body.content || false, lang: languages.getKey(req.body.lang) || 1, - hidden: req.body.hidden || 0, + hidden: req.body.hidden === "on" || false, reply: req.body.reply || 0 }; if(!data.content) @@ -38,7 +38,9 @@ export default express.Router() }); Map.prototype.getKey = function(val) { - for (let [key, value] of this) + if(!val) + return 1; + for(let [key, value] of this) if(value.toLowerCase() === val.toLowerCase()) return key; return false; diff --git a/src/routes/r/user.mjs b/src/routes/r/user.mjs new file mode 100644 index 0000000..4896385 --- /dev/null +++ b/src/routes/r/user.mjs @@ -0,0 +1,14 @@ +import express from "express"; + +import db from "../../lib/sql"; + +export default express.Router() + .get("/", (req, res) => { + res.render("login"); + }) + .get("/register", (req, res) => { + res.send("WIP"); + }) + .get("/lost-password", (req, res) => { + res.send("WIP"); + }); \ No newline at end of file diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index c342dbe..e78a681 100644 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -2,12 +2,14 @@ fpaste + +
@@ -35,6 +37,7 @@ + + \ No newline at end of file diff --git a/views/login.handlebars b/views/login.handlebars new file mode 100644 index 0000000..67d0500 --- /dev/null +++ b/views/login.handlebars @@ -0,0 +1,7 @@ +

User login

+
+

Email:


+

Password:


+ +
+

No user account yet? Register now for free. Forgot your password? Get a new one.

\ No newline at end of file