Save record on server

This commit is contained in:
KGrzeg 2021-10-17 23:47:52 +02:00
parent a38072214e
commit a575d447f9
9 changed files with 68 additions and 36 deletions

View file

@ -7,7 +7,7 @@ import cors from 'cors'
import auth from './Auth.js'
import db from './Database.js'
import jg from './JusticeGuard'
import jg from './JusticeGuard.js'
const protect = (req, res, next) => {
const authHeader = req.headers.authorization;
@ -76,7 +76,7 @@ app.post("/login", neededArguments(['key']), async (req, res) => {
res.json(user)
})
app.post("/record", neededArguments(['points', 'shoots', 'time']), jg, async (req, res) => {
app.post("/record", protect, neededArguments(['points', 'shoots', 'time']), jg, async (req, res) => {
db.updateRecord(req.user.name, req.body.points)
res.json({