mirror of
https://github.com/originalmk/skrytka-app.git
synced 2025-01-18 08:19:17 +00:00
Repaired /quiz-results bug and removed unnecessary code
This commit is contained in:
parent
53c923581b
commit
92abec5fb3
52
app.js
52
app.js
@ -514,7 +514,7 @@ app.post('/quiz-results', async (req, res) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if(points <= 0 || points >= 10) {
|
||||
if(points < 0 || points > 10) {
|
||||
res.status(400);
|
||||
res.json({
|
||||
fieldErrors: {
|
||||
@ -525,10 +525,6 @@ app.post('/quiz-results', async (req, res) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Zapis do sesji lub do bazy
|
||||
console.log('Zapis', req.body);
|
||||
|
||||
|
||||
if(!req.session.accountNickname) {
|
||||
// Zapis do sesji
|
||||
if(!req.session.quizResults) {
|
||||
@ -559,52 +555,6 @@ app.post('/quiz-results', async (req, res) => {
|
||||
res.sendStatus(204);
|
||||
});
|
||||
|
||||
// TESTY CIASTECZEK:
|
||||
/* app.get('/cookieaddone', (req, res) => {
|
||||
req.session.counter = (req.session.counter || 0) + 1
|
||||
res.status(200);
|
||||
res.send('Added!');
|
||||
});
|
||||
|
||||
app.get('/cookiegetvalue', (req, res) => {
|
||||
const val = req.session.counter || 0;
|
||||
res.status(200);
|
||||
res.send(`Value: ${val}`);
|
||||
}); */
|
||||
|
||||
// TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
// CAUTION: Only for testing purposes! Should be deleted ASAP when not needed anymore.
|
||||
app.get('/simulate-login', (req, res) => {
|
||||
const nickToAuth = req.query.nickname;
|
||||
|
||||
if(!nickToAuth) {
|
||||
res.status(400);
|
||||
res.send('You must pass nickname as query parameter to simulate login');
|
||||
return;
|
||||
}
|
||||
|
||||
req.session.accountNickname = nickToAuth;
|
||||
res.status(200);
|
||||
res.send(`Logged in as ${nickToAuth}`);
|
||||
});
|
||||
|
||||
app.get('/simulate-logout', (req, res) => {
|
||||
if(!req.session.accountNickname) {
|
||||
res.status(401);
|
||||
res.json({
|
||||
fieldErrors: {},
|
||||
otherErrors: [
|
||||
'Użytkownik nie jest zalogowany!'
|
||||
]
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
req.session.destroy();
|
||||
res.status(200);
|
||||
res.send(`Logged out!`);
|
||||
});
|
||||
|
||||
// This should remain at the end of all routes
|
||||
// It will direct every not matched route to index.html file
|
||||
app.get('/*', function (req, res) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user