Základ zobrazování ověřených uživatelů
This commit is contained in:
@@ -8,7 +8,7 @@ import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
import { getMenuSladovnicka, getMenuTechTower, getMenuUMotliku } from "./restaurants";
|
||||
import { getQr } from "./qr";
|
||||
import { generateToken, getLogin, verify } from "./auth";
|
||||
import { generateToken, getLogin, getTrusted, verify } from "./auth";
|
||||
import { Locations, Restaurants } from "../../types";
|
||||
|
||||
const ENVIRONMENT = process.env.NODE_ENV || 'production';
|
||||
@@ -62,7 +62,7 @@ app.post("/api/login", (req, res) => {
|
||||
// Autentizace pomocí trusted headers
|
||||
const remoteUser = req.header('remote-user');
|
||||
if (remoteUser && remoteUser.length > 0) {
|
||||
res.status(200).json(generateToken(remoteUser));
|
||||
res.status(200).json(generateToken(remoteUser, true));
|
||||
return;
|
||||
}
|
||||
// Klasická autentizace loginem
|
||||
@@ -70,7 +70,7 @@ app.post("/api/login", (req, res) => {
|
||||
throw Error("Nebyl předán login");
|
||||
}
|
||||
// TODO zavést podmínky pro délku loginu (min i max)
|
||||
res.status(200).json(generateToken(req.body.login));
|
||||
res.status(200).json(generateToken(req.body.login, false));
|
||||
});
|
||||
|
||||
// TODO dočasné řešení - QR se zobrazuje přes <img>, nemáme sem jak dostat token
|
||||
@@ -207,8 +207,9 @@ app.post("/api/finishDelivery", (req, res) => {
|
||||
|
||||
app.post("/api/addChoice", (req, res) => {
|
||||
const login = getLogin(parseToken(req));
|
||||
const trusted = getTrusted(parseToken(req));
|
||||
if (req.body.locationIndex > -1) {
|
||||
const data = addChoice(login, req.body.locationIndex, req.body.foodIndex);
|
||||
const data = addChoice(login, trusted, req.body.locationIndex, req.body.foodIndex);
|
||||
io.emit("message", data);
|
||||
res.status(200).json(data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user