From deaa8ded34773954aed88f78897cdd820708feaf Mon Sep 17 00:00:00 2001 From: slynn1324 Date: Mon, 1 Feb 2021 16:15:01 -0600 Subject: [PATCH] added settings page and enabled disabling registration and admin user management --- README.md | 1 + client/components/about.js | 40 +++- client/components/navbar.js | 15 +- package-lock.json | 17 ++ package.json | 1 + server/auth.js | 33 ++- server/dao.js | 101 +++++++- server/server.js | 126 +++++++++- templates/{login.html => login.eta} | 4 +- templates/{register.html => register.eta} | 2 +- templates/settings.eta | 267 ++++++++++++++++++++++ utils/change-password.js | 48 ++++ utils/image-test.js | 16 ++ utils/rotate-key.js | 3 + 14 files changed, 658 insertions(+), 16 deletions(-) rename templates/{login.html => login.eta} (97%) rename templates/{register.html => register.eta} (99%) create mode 100644 templates/settings.eta create mode 100644 utils/change-password.js create mode 100644 utils/image-test.js create mode 100644 utils/rotate-key.js diff --git a/README.md b/README.md index cc06db9..6338dbb 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ There is trivial security on the web pages to allow for multiple user support. - download icon > [Download by Yoyo from the Noun Project](https://thenounproject.com/term/download/2120379/) - share icon > [Share by Тимур Минвалеев from the Noun Project](https://thenounproject.com/term/share/1058858/) - done icon > [done by Viktor Ostrovsky from the Noun Project](https://thenounproject.com/term/done/587164/) +- settings icon > [setting by LUTFI GANI AL ACHMAD from the Noun Project](https://thenounproject.com/term/settings/3291880/) ## server diff --git a/client/components/about.js b/client/components/about.js index 1e2cf17..c6b3fe2 100644 --- a/client/components/about.js +++ b/client/components/about.js @@ -3,18 +3,51 @@ app.addSetter('aboutModal.open', (data) => { }); app.addSetter('aboutModal.close', (data) => { + data.apiKey = null; + data.showApiKey = false; data.aboutModal.active = false; }); +app.addSetter('about.showApiKey', async (data, apiKey) => { + data.apiKey = apiKey; + data.showApiKey = true; +}); + +async function showApiKey(){ + let result = await fetch("/api/apikey"); + let json = await result.json(); + let apiKey = json.apiKey; + store.do('about.showApiKey', encodeURIComponent(apiKey)); +} + app.addComponent('aboutModal', (store) => { return new Reef("#aboutModal", { store: store, template: (data) => { + + let apiKeyElement = ""; + if ( data.showApiKey ){ + apiKeyElement = /*html*/` +
+

api key for ${data.user.name}:

+ +

+
+ `; + } + return /*html*/`