-
Notifications
You must be signed in to change notification settings - Fork 858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that the user receives the authenticated user token. #312
Comments
`const express = require('express'); const USERS = []; const QUESTIONS = [{ const SUBMISSIONS = []; app.use(express.json()); app.post('/signup', function(req, res) { if (!email || !password) { const user = USERS.find(user => user.email === email); if (user) { USERS.push({ email, password }); res.sendStatus(200); app.post('/login', function(req, res) { if (!email || !password) { const user = USERS.find(user => user.email === email); if (!user || user.password !== password) { const token = Math.random().toString(36).substring(7); res.json({ token }); app.get('/questions', function(req, res) { app.get('/submissions', function(req, res) { if (!problemIndex || isNaN(problemIndex)) { const submissions = SUBMISSIONS.filter(submission => submission.problemIndex === Number(problemIndex)); res.json(submissions); app.post('/submissions', function(req, res) { if (!problemIndex || isNaN(problemIndex)) { if (!code) { const accepted = Math.random() < 0.5; const submission = { SUBMISSIONS.push(submission); res.json(submission); app.listen(port, function() { |
There seems to be a syntax error in the code const USERS = []; const QUESTIONS = [{ const SUBMISSIONS = []; app.use(express.json()); app.post('/signup', function(req, res) { if (!email || !password) { const user = USERS.find(user => user.email === email); if (user) { USERS.push({ email, password }); res.sendStatus(200); app.post('/login', function(req, res) { if (!email || !password) { const user = USERS.find(user => user.email === email); if (!user || user.password !== password) { const token = Math.random().toString(36).substring(7); res.json({ token }); app.get('/questions', function(req, res) { app.get('/submissions', function(req, res) { if (!problemIndex || isNaN(problemIndex)) { const submissions = SUBMISSIONS.filter(submission => submission.problemIndex === Number(problemIndex)); res.json(submissions); app.post('/submissions', function(req, res) { if (!problemIndex || isNaN(problemIndex)) { if (!code) { const accepted = Math.random() < 0.5; const submission = { SUBMISSIONS.push(submission); res.json(submission); app.listen(port, function() { |
No description provided.
The text was updated successfully, but these errors were encountered: