Removed everything minecraft-related, added image scope to oauth, replaced github with gitlab.

This commit is contained in:
Evert Prants 2018-06-05 12:51:49 +03:00
parent c184695b04
commit 5534eb0a18
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
11 changed files with 3967 additions and 2701 deletions

6460
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "icynet.eu",
"version": "0.9.0",
"version": "0.9.1",
"description": "Icy Network web server",
"main": "icynet.eu.js",
"scripts": {
@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/IcyNet/IcyNet.eu.git"
"url": "git+https://gitlab.icynet.eu/IcyNetwork/IcyNet.eu.git"
},
"keywords": [
"website",
@ -30,55 +30,55 @@
},
"homepage": "https://github.com/IcyNet/IcyNet.eu#readme",
"dependencies": {
"babel-core": "^6.26.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-core": "^6.26.3",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"bcryptjs": "^2.4.3",
"bluebird": "^3.5.1",
"body-parser": "^1.18.2",
"connect-redis": "^3.3.2",
"body-parser": "^1.18.3",
"connect-redis": "^3.3.3",
"connect-session-knex": "^1.4.0",
"email-templates": "^2.7.1",
"express": "^4.16.2",
"express-rate-limit": "^2.9.0",
"express": "^4.16.3",
"express-rate-limit": "^2.11.0",
"express-session": "^1.15.6",
"feed": "^1.1.1",
"fs-extra": "^4.0.2",
"gm": "^1.23.0",
"knex": "^0.13.0",
"multiparty": "^4.1.3",
"fs-extra": "^4.0.3",
"gm": "^1.23.1",
"knex": "^0.14.6",
"multiparty": "^4.1.4",
"mysql": "^2.15.0",
"nodemailer": "^4.4.0",
"nodemailer": "^4.6.5",
"notp": "^2.0.3",
"oauth-libre": "^0.9.17",
"objection": "^0.8.9",
"pug": "^2.0.0-rc.4",
"serve-favicon": "^2.4.5",
"pug": "^2.0.3",
"serve-favicon": "^2.5.0",
"stylus": "^0.54.5",
"thirty-two": "^1.0.2",
"toml": "^2.3.3",
"uuid": "^3.1.0",
"vue": "^2.5.9"
"uuid": "^3.2.1",
"vue": "^2.5.16"
},
"devDependencies": {
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"bootstrap": "^4.0.0",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"bootstrap": "^4.1.1",
"concurrently": "^3.5.1",
"eslint-plugin-import": "^2.8.0",
"jquery": "^3.2.1",
"eslint-plugin-import": "^2.12.0",
"jquery": "^3.3.1",
"morgan": "^1.9.0",
"mustache": "^2.3.0",
"popper.js": "^1.12.9",
"popper.js": "^1.14.3",
"standard": "^10.0.3",
"uglifyjs-webpack-plugin": "^1.1.2",
"vue-clickaway": "^2.1.0",
"vue-loader": "^13.5.0",
"vue-resource": "^1.3.4",
"uglifyjs-webpack-plugin": "^1.2.5",
"vue-clickaway": "^2.2.2",
"vue-loader": "^13.7.2",
"vue-resource": "^1.5.1",
"vue-router": "^3.0.1",
"vue-template-compiler": "^2.5.9",
"vue-template-compiler": "^2.5.16",
"watch": "^1.0.2",
"webpack": "^3.10.0",
"webpack-merge": "^4.1.1"
"webpack": "^3.12.0",
"webpack-merge": "^4.1.2"
},
"standard": {
"env": {

View File

@ -1,53 +0,0 @@
import crypto from 'crypto'
import API from './index'
import Model from './models'
const mAPI = {
getMinecraftUsername: async function (user) {
user = await API.User.ensureObject(user)
let verified = await Model.MinecraftMember.query().where('user_id', user.id)
if (verified.length) return verified[0].name
return null
},
getToken: async function (user) {
user = await API.User.ensureObject(user)
let verified = await Model.MinecraftMember.query().where('user_id', user.id)
if (verified.length) return {token: null, mcu: verified[0]}
let token = await Model.MinecraftToken.query().where('user_id', user.id)
if (!token.length) {
token = crypto.randomBytes(4).toString('hex')
await Model.MinecraftToken.query().insert({
token: token,
user_id: user.id,
created_at: new Date()
})
} else {
token = token[0].token
}
return {token: token, mcu: null}
},
verifyToken: async function (raw, name, uuid) {
let token = await Model.MinecraftToken.query().where('token', raw)
if (!token.length) return null
token = token[0]
await Model.MinecraftMember.query().insert({
uuid: uuid,
name: name,
user_id: token.user_id,
created_at: new Date()
})
await Model.MinecraftToken.query().delete().where('id', token.id)
return true
}
}
module.exports = mAPI

View File

@ -9,13 +9,11 @@ import wrap from '../../scripts/asyncRoute'
import http from '../../scripts/http'
import API from '../api'
import News from '../api/news'
import Minecraft from '../api/minecraft'
import emailer from '../api/emailer'
import apiRouter from './api'
import oauthRouter from './oauth2'
import adminRouter from './admin'
import mcRouter from './minecraft'
let router = express.Router()
@ -283,17 +281,8 @@ router.get('/user/manage/email', ensureLogin, wrap(async (req, res) => {
router.get('/donate', wrap(async (req, res, next) => {
if (!config.donations || !config.donations.business) return next()
let mcu = null
if (config.donations.minecraft && req.session.user) {
mcu = await Minecraft.getMinecraftUsername(req.session.user)
}
let cfg = Object.assign({
minecraftName: mcu
}, config.donations)
res.render('donate', cfg)
res.render('donate', config.donations)
}))
/*
@ -842,7 +831,6 @@ router.get('/logout', (req, res) => {
router.use('/api', apiRouter)
router.use('/admin', adminRouter)
router.use('/mc', mcRouter)
/*
NO ROUTES BEYOND THIS POINT

View File

@ -1,24 +0,0 @@
import express from 'express'
import ensureLogin from '../../scripts/ensureLogin'
import wrap from '../../scripts/asyncRoute'
import Minecraft from '../api/minecraft'
let router = express.Router()
router.get('/', ensureLogin, wrap(async (req, res) => {
let token = await Minecraft.getToken(req.session.user)
res.render('minecraft/index', {token: token.token, mcu: token.mcu})
}))
router.post('/verify/', wrap(async (req, res) => {
if (!req.body.name || !req.body.uuid || !req.body.token) return res.status(400).jsonp({error: 'Missing field.'})
let verify = await Minecraft.verifyToken(req.body.token, req.body.name, req.body.uuid)
if (!verify) return res.status(400).jsonp({error: 'Already verified.'})
res.status(200).end()
}))
module.exports = router

View File

@ -4,6 +4,7 @@ import UAPI from '../api'
import OAuth2 from '../api/oauth2'
import RateLimit from 'express-rate-limit'
import wrap from '../../scripts/asyncRoute'
import config from '../../scripts/load-config.js'
let router = express.Router()
let oauth = new OAuth2()
@ -44,8 +45,7 @@ router.get('/user', oauth.bearer, wrap(async (req, res) => {
id: user.id,
uuid: user.uuid,
username: user.username,
display_name: user.display_name,
avatar_file: user.avatar_file
display_name: user.display_name
}
// Include Email
@ -53,6 +53,12 @@ router.get('/user', oauth.bearer, wrap(async (req, res) => {
udata.email = user.email
}
// Include Avatar
if (accessToken.scope.indexOf('image') !== -1 && user.avatar_file) {
udata.image = `${config.server.domain}/api/avatar/${user.uuid}`
udata.image_file = user.avatar_file
}
// Include privilege number
if (accessToken.scope.indexOf('privilege') !== -1) {
udata.privilege = user.nw_privilege

View File

@ -396,8 +396,9 @@ noscript
border-radius: 100px
padding: 0 2px
margin: 5px
&#github
background-color: #000
&#gitlab
background-color: #292961
font-size: 115%
&#twitter
background-color: #03a9f4
&#discord
@ -418,6 +419,8 @@ noscript
width: 22px
height: 22px
display: block
&:hover
color: #ddd
@media all and (max-width: 500px)
section

View File

@ -29,24 +29,9 @@ block body
option(value="EUR") EUR
option(value="USD") USD
if user
if minecraftName
input#custominfo(type="hidden", name="custom", value="userid:" + user.id + ",mcu:" + minecraftName)
else
input#custominfo(type="hidden", name="custom", value="userid:" + user.id)
input#custominfo(type="hidden", name="custom", value="userid:" + user.id)
else
input#custominfo(type="hidden", name="custom", value="")
if minecraft
if minecraftName
p Donation will also be forwarded to the Minecraft server as
b= minecraftName
| .
else
.form-check.form-check-inline
input.form-check-input(id="mcinclude" type="checkbox" checked="false")
label.form-check-label(for="mcinclude") Include Minecraft Username
.mcuname.form-group(style="display: none;")
label(for="mcusername") Minecraft Username
input.form-control(id="mcusername", autocomplete="off")
.buttoncont
a.btn.btn-primary.text-light(name="submit", onclick="$(this).closest('form').submit()")
i.fa.fa-fw.fa-paypal

View File

@ -38,9 +38,9 @@ block body
span.circular-header.bg-success
i.fa.fa-fw.fa-github
h2 Open Source
p All of our services are Free and Open Source Software (FOSS) hosted on GitHub.
p All of our services are Free and Open Source Software (FOSS) hosted on our own GitLab instance.
p
a.btn.btn-secondary(href="https://github.com/IcyNet", target="_blank") Browse Repositories
a.btn.btn-secondary(href="https://gitlab.icynet.eu/IcyNetwork", target="_blank") Browse Repositories
.col-lg-4
span.circular-header.bg-info
i.fa.fa-fw.fa-users

View File

@ -100,8 +100,8 @@ html
| ·
a(href="/donate") Donate
.d-flex.justify-content-center
a.btn-social#github(href="https://github.com/IcyNet/" target="_blank")
i.fa.fa-fw.fa-github
a.btn-social#gitlab(href="https://gitlab.icynet.eu/IcyNetwork/" target="_blank")
i.fa.fa-fw.fa-gitlab
a.btn-social#twitter(href="https://twitter.com/IcyNet" target="_blank")
i.fa.fa-fw.fa-twitter
a.btn-social#discord(href="https://discord.gg/Xe7MKSx" target="_blank")

View File

@ -1,15 +0,0 @@
extends ../layout.pug
block title
|Icy Network - Minecraft Server
block body
.container
h1 Minecraft Server
p Link your Icy Network account with your Minecraft account on our server
if token
p Run the following command on the Minecraft Server:
code /verify #{token}
else
p You've already logged in as
b= mcu.name