From 913309c7ab22849e98aebf52b0b9ddbf8edf3c90 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sat, 5 Jan 2019 01:10:23 +0200 Subject: [PATCH] Maintenance commit Sat Jan 5 01:10:23 EET 2019 --- README.md | 24 +++++++------------ development | 2 -- install | 6 ----- package-lock.json | 38 ++++++++++++++++++++---------- package.json | 8 +++---- scripts/http.js | 4 ++-- scripts/logger.js | 12 ++++++++-- server/routes/admin.js | 1 + server/routes/index.js | 3 ++- src/script/component/UserModal.vue | 2 +- src/style/admin.styl | 10 ++++++++ 11 files changed, 64 insertions(+), 46 deletions(-) delete mode 100755 development delete mode 100755 install diff --git a/README.md b/README.md index 5a7df1e..de779bf 100644 --- a/README.md +++ b/README.md @@ -2,28 +2,20 @@ Icy Network Primary Web Application - Authentication and News ## About Icy Network -Icy Network is a community network aimed at anyone who likes friendly discussions and playing multiplayer games, such as Minecraft. +Icy Network is a SSO (Single-Sign On) service provider - for communities. This application is used for authentication services such as OAuth2 in order to unite our websites with a single login and as a central news outlet for Icy Network services. -### Currently IcyNet-managed community platforms -* mc.icynet.eu - Minecraft Server -* [Discord server](https://discord.gg/Xe7MKSx) -* icynet.ml - IRC Network +## Requirements +* [Node.js](https://nodejs.org/en/) +* A running instance of [Redis](https://redis.io/) +* A database of your choice. See [knex installation](https://knexjs.org/#Installation-node) for a list of supported database drivers. -More to come! - -## The Goal of this Application -This application is used for authentication services such as OAuth2 in order to unite our websites with a single login and as a central news outlet for Icy Network services. - -## Setup -The first time you run the application, it will migrate the database and that may take a while. **You will also need a running instance of `redis-server` for session storage!** ### Development 1. Clone this repository and `cd` into it 2. `npm install` - Get all the dependencies -3. `cp config.example.toml config.toml` - Copy the configuration -4. `npm run watch` - Run the style and front-end script watch task -5. `npm start -- -d` - Start the application in development mode +3. `cp config.example.toml config.toml && $EDITOR config.toml` - Copy the configuration (and edit it) +4. `npm run watch` - Run the server and front-end watch task, which also starts the application in development mode -There is also a watch mode for the server. To enable `server` file tree watching you must provide both `-d` and `-w` as parameters. This task will reset all workers when any file in the `server` directory changes, enabling for live debugging. +You can run the application in development mode using `npm start -- -d` if you do not need the watch tasks. ### Production 1. `npm run build` - Build the front-end diff --git a/development b/development deleted file mode 100755 index 7840285..0000000 --- a/development +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./node_modules/.bin/concurrently --kill-others "npm run watch" "npm run start -- -d -w" diff --git a/install b/install deleted file mode 100755 index b337ccc..0000000 --- a/install +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -npm install -cp config.example.toml config.toml -$EDITOR config.toml -echo "Run the program with `./development` in development mode or build the project" -echo "using `npm run build` and then `npm start` for production!" diff --git a/package-lock.json b/package-lock.json index 4a4cf83..d441d82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "icynet.eu", - "version": "0.9.1", + "version": "0.9.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1292,11 +1292,18 @@ "dev": true }, "basic-auth": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz", - "integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "5.1.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } } }, "bcrypt-pbkdf": { @@ -5722,9 +5729,9 @@ "integrity": "sha1-4gD/TdgjcX+OBWOzLj9UgfyiYrI=" }, "merge": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/merge/-/merge-1.2.0.tgz", - "integrity": "sha1-dTHjnUlJwoGma4xabgJl6LBYlNo=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/merge/-/merge-1.2.1.tgz", + "integrity": "sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==", "dev": true }, "merge-descriptors": { @@ -5880,15 +5887,22 @@ } }, "morgan": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz", - "integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz", + "integrity": "sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA==", "requires": { "basic-auth": "~2.0.0", "debug": "2.6.9", - "depd": "~1.1.1", + "depd": "~1.1.2", "on-finished": "~2.3.0", "on-headers": "~1.0.1" + }, + "dependencies": { + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + } } }, "move-concurrently": { diff --git a/package.json b/package.json index 01174c3..0598e40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "icynet.eu", - "version": "0.9.2", + "version": "0.9.3", "description": "Icy Network web server", "main": "icynet.eu.js", "scripts": { @@ -26,9 +26,9 @@ "author": "Icy Network", "license": "MIT", "bugs": { - "url": "https://github.com/IcyNet/IcyNet.eu/issues" + "url": "https://gitlab.icynet.eu/IcyNetwork/issues" }, - "homepage": "https://github.com/IcyNet/IcyNet.eu#readme", + "homepage": "https://icynet.eu", "dependencies": { "babel-core": "^6.26.3", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", @@ -66,7 +66,7 @@ "concurrently": "^3.6.0", "eslint-plugin-import": "^2.13.0", "jquery": "^3.3.1", - "morgan": "^1.9.0", + "morgan": "^1.9.1", "mustache": "^2.3.0", "popper.js": "^1.14.3", "standard": "^10.0.3", diff --git a/scripts/http.js b/scripts/http.js index ec33af0..b7fe832 100644 --- a/scripts/http.js +++ b/scripts/http.js @@ -10,7 +10,7 @@ function HTTP_GET (link, headers = {}, lback) { port: parsed.port, path: parsed.path, headers: { - 'User-Agent': 'Squeebot/Commons-2.0.0', + 'User-Agent': 'Icy Network Back-end (icynet.eu)', 'Accept': '*/*', 'Accept-Language': 'en-GB,enq=0.5' } @@ -72,7 +72,7 @@ function HTTP_POST (link, headers = {}, data) { headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': Buffer.byteLength(postData), - 'User-Agent': 'Squeebot/Commons-2.0.0' + 'User-Agent': 'Icy Network Back-end (icynet.eu)' } } diff --git a/scripts/logger.js b/scripts/logger.js index 9c11bfa..ad92049 100644 --- a/scripts/logger.js +++ b/scripts/logger.js @@ -53,13 +53,21 @@ console.error = function () { async function initializeLogger () { let logPath = path.resolve(config.logger.file) + // Only throw bad permission errors try { await fs.access(logPath, fs.W_OK) + } catch (e) { + if (e.code !== 'ENOENT') throw e + } + + try { lfs = fs.createWriteStream(logPath, {flags: 'a'}) } catch (e) { lfs = null console.error('Failed to initiate log file write stream') - console.error(e.stack) + + // Rethrow error + throw e } } @@ -78,5 +86,5 @@ module.exports = function () { // Create log file write stream if (!config.logger || !config.logger.write) return - initializeLogger() + initializeLogger().catch((e) => console.error(e)) } diff --git a/server/routes/admin.js b/server/routes/admin.js index 6e78e78..b40ebce 100644 --- a/server/routes/admin.js +++ b/server/routes/admin.js @@ -195,6 +195,7 @@ apiRouter.get('/search/users', wrap(async (req, res) => { * OAuth2 Data * =============== */ + apiRouter.get('/clients', wrap(async (req, res) => { let page = parseInt(req.query.page) if (isNaN(page) || page < 1) { diff --git a/server/routes/index.js b/server/routes/index.js index 23888c5..6f03103 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -96,6 +96,7 @@ router.use('/oauth2', oauthRouter) RENDER VIEWS ================ */ + router.get('/', (req, res) => { res.render('index') }) @@ -833,7 +834,7 @@ router.use('/api', apiRouter) router.use('/admin', adminRouter) /* - NO ROUTES BEYOND THIS POINT + FALLBACK ROUTES BEYOND THIS POINT */ // Handle 'Failed to lookup view' errors diff --git a/src/script/component/UserModal.vue b/src/script/component/UserModal.vue index dbc3e23..a23aea9 100644 --- a/src/script/component/UserModal.vue +++ b/src/script/component/UserModal.vue @@ -16,7 +16,7 @@ .form-group label(for="privilege") Privilege input(type="range" min="0" max="5" step="1" id="privilege" name="privilege" v-model="nw_privilege") - span {{ nw_privilege }} + span#priv-num {{ nw_privilege }} .form-check input.form-check-input(type="checkbox" id="activated" name="activated" v-model="activated") label.form-check-label(for="activated") Activated diff --git a/src/style/admin.styl b/src/style/admin.styl index 3d7eb6b..1dbd685 100644 --- a/src/style/admin.styl +++ b/src/style/admin.styl @@ -34,6 +34,7 @@ body .list-item background-color: #f5f5f5 padding: 10px + flex-wrap: nowrap &:nth-child(even) background-color: #fff @@ -165,3 +166,12 @@ body form .message display: none + +#priv-num + padding: 0 4px + vertical-align: top + +input[type=range] + display: inline-block + margin: 0 15px + vertical-align: top