From fae5e54066b39bea89d416595fa379791a133ab3 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sun, 14 Jun 2020 15:15:15 +0200 Subject: [PATCH] Branding and auth views --- assets/js/fm.js | 2 +- package.json | 6 ++-- src/controllers/AboutController.ts | 3 +- src/controllers/FileController.ts | 7 ++-- src/main.ts | 3 +- views/auth.njk | 42 ++++++++++++++++++++++ views/file-manager.njk | 2 +- views/layouts/base.njk | 7 ++-- views/magic_link.njk | 19 ++++++++++ views/magic_link_lobby.njk | 58 ++++++++++++++++++++++++++++++ 10 files changed, 138 insertions(+), 11 deletions(-) create mode 100644 views/auth.njk create mode 100644 views/magic_link.njk create mode 100644 views/magic_link_lobby.njk diff --git a/assets/js/fm.js b/assets/js/fm.js index 65f6307..3e74c5c 100644 --- a/assets/js/fm.js +++ b/assets/js/fm.js @@ -4,6 +4,6 @@ document.addEventListener('DOMContentLoaded', () => { neverExpireCheckbox.addEventListener('change', () => { // noinspection RedundantConditionalExpressionJS - expireAfterDaysField.disabled = neverExpireCheckbox.value ? true : false; + expireAfterDaysField.disabled = neverExpireCheckbox.checked ? true : false; }); }); \ No newline at end of file diff --git a/package.json b/package.json index 9dab188..e1a56eb 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "aldap", + "name": "ily.li", "version": "0.1.0", - "description": "Authentication LDAP server", - "repository": "git@gitlab.com:ArisuOngaku/aldap.git", + "description": "Self-hosted file pusher", + "repository": "git@gitlab.com:ArisuOngaku/ily.li.git", "author": "Alice Gaudon ", "private": true, "main": "dist/main.js", diff --git a/src/controllers/AboutController.ts b/src/controllers/AboutController.ts index f59fa79..a4b3e3e 100644 --- a/src/controllers/AboutController.ts +++ b/src/controllers/AboutController.ts @@ -3,7 +3,8 @@ import {Request, Response} from "express"; export default class AboutController extends Controller { routes(): void { - this.get('/about', this.getAbout, 'about'); + this.get('/', this.getAbout, 'home'); + this.get('/', this.getAbout, 'about'); } private async getAbout(req: Request, res: Response) { diff --git a/src/controllers/FileController.ts b/src/controllers/FileController.ts index 7f7ccc7..05125fd 100644 --- a/src/controllers/FileController.ts +++ b/src/controllers/FileController.ts @@ -118,12 +118,15 @@ export default class FileController extends Controller { return slug; } i++; - } while (i < tries) + } while (i < tries); throw new ServerError('Failed to generate slug; newly generated slug size should be increased by 1.'); } } -const FILE_UPLOAD_MAX_SIZE_MIDDLEWARE = express.urlencoded({limit: config.get('max_upload_size')}); +const FILE_UPLOAD_MAX_SIZE_MIDDLEWARE = express.urlencoded({ + limit: config.get('max_upload_size'), + extended: true, +}); const FILE_UPLOAD_MIDDLEWARE = fileUpload({ tempFileDir: 'storage/tmp', diff --git a/src/main.ts b/src/main.ts index a73d671..1706351 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,9 @@ import Logger from "wms-core/Logger"; import App from "./App"; +import config from "config"; (async () => { - const app = new App(4899); + const app = new App(config.get('port')); await app.start(); })().catch(err => { Logger.error(err); diff --git a/views/auth.njk b/views/auth.njk new file mode 100644 index 0000000..3a6c7d3 --- /dev/null +++ b/views/auth.njk @@ -0,0 +1,42 @@ +{% extends 'layouts/base.njk' %} +{% import 'macros.njk' as macros %} + +{% set title = 'Authentication / Registration' %} +{% set decription = 'Join Watch My Stream and power up your streams!' %} +{% set h1 = 'Authentication and registration' %} + +{% block body %} +
+
+ {% if register_confirm_email %} +
+

Register

+ {{ macros.message('question', 'Do you wish to create a new account with ' + register_confirm_email + '?', false, false) }} + {{ macros.message('warning', 'If you already have an account, please log in with your existing email first and then add your new email in the Account page.', false, true) }} + + + +
+
Email: {{ register_confirm_email }}
+
+ + Go back + + + {{ macros.csrf(getCSRFToken) }} +
+ {% else %} +
+

Log in or register

+ {# {{ macros.message('info', 'If we don\'t find your email address in our database, you will be able to register.', false, true) }}#} +
+ {{ macros.field(_locals, 'email', 'email', query.email or '', 'Your email address', "If we don't find your email address in our database, you will be able to register.", 'required') }} +
+ + + {{ macros.csrf(getCSRFToken) }} +
+ {% endif %} +
+
+{% endblock %} diff --git a/views/file-manager.njk b/views/file-manager.njk index ab930b0..f54c164 100644 --- a/views/file-manager.njk +++ b/views/file-manager.njk @@ -15,7 +15,7 @@

Upload a file

- {{ macros.field(_locals, 'file', 'upload', '', 'Choose wisely', 'The maximum upload size is' + max_upload_size, validation_attributes='required') }} + {{ macros.field(_locals, 'file', 'upload', '', 'Choose wisely', 'The maximum upload size is ' + max_upload_size, validation_attributes='required') }} {{ macros.field(_locals, 'number', 'expire_after_days', '30', 'How many days to delete this file after', null, validation_attributes='max="1825"') }} diff --git a/views/layouts/base.njk b/views/layouts/base.njk index 2a747de..edbb5c7 100644 --- a/views/layouts/base.njk +++ b/views/layouts/base.njk @@ -12,12 +12,15 @@ {% endblock %} {% block header %} - + @@ -40,4 +43,4 @@ {% endblock %} -{% block footer %}Example app v{{ app_version }} - all rights reserved.{% endblock %} \ No newline at end of file +{% block footer %}ily.li v{{ app_version }} - all rights reserved.{% endblock %} \ No newline at end of file diff --git a/views/magic_link.njk b/views/magic_link.njk new file mode 100644 index 0000000..41e6e17 --- /dev/null +++ b/views/magic_link.njk @@ -0,0 +1,19 @@ +{% extends 'layouts/base.njk' %} +{% import 'macros.njk' as macros %} + +{% set actionType = magicLink.action_type %} +{% set title = 'WMS: Magic Link' + (' - ' + actionType if actionType) %} +{% set h1 = 'Magic Link' + (' - ' + actionType if actionType) %} + +{% block body %} +
+
+ {% if err %} + {{ macros.message('error', err) }} + {% else %} + {{ macros.message('success', 'Success!') }} +

You can now close this page.

+ {% endif %} +
+
+{% endblock %} \ No newline at end of file diff --git a/views/magic_link_lobby.njk b/views/magic_link_lobby.njk new file mode 100644 index 0000000..e1a15a4 --- /dev/null +++ b/views/magic_link_lobby.njk @@ -0,0 +1,58 @@ +{% extends 'layouts/base.njk' %} +{% import 'macros.njk' as macros %} + +{% set title = 'Authentication lobby' %} +{% set h1 = 'Authentication lobby' %} + +{% block body %} +
+
+ {{ macros.message('success', 'We sent a link to ' + email + '. To authenticate, open it from any device.') }} + {{ macros.message('info', 'This link will be valid for and can only be used once.', true, true) }} + +

Waiting for you to open the link...

+
+
+{% endblock %} + +{% block scripts %} + + + {{ macros.websocket(websocketUrl, 'websocketListen', 1, 'isValid') }} +{% endblock %} \ No newline at end of file