-
Notifications
You must be signed in to change notification settings - Fork 445
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
Auth app #331
base: master
Are you sure you want to change the base?
Auth app #331
Conversation
…an authenticated endpoint
fixed some things with localstorage, can now refresh without being lo…
…quirements, also som error-messages
…omatically after 2 seconds
fixed so that after a user registers, it comes to the signin-page aut…
Updated Readme.
Added readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done creating this authentication app! It works well 🚀
const authenticateUser = async (req, res, next) => { | ||
try { | ||
const user = await User.findOne({ | ||
accessToken: req.header("Authorization"), | ||
}); | ||
if (user) { | ||
req.user = user; | ||
next(); | ||
} else { | ||
res.status(401).json({ | ||
message: "Authentication missing or invalid.", | ||
loggedOut: true, | ||
}); | ||
} | ||
} catch (err) { | ||
res | ||
.status(500) | ||
.json({ message: "Internal server error", error: err.message }); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐
res.json(endpoints); | ||
}); | ||
|
||
app.post("/register", async (req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good! Just remember to try to name endpoints after what they return or in this case create. For example: /users
frontend/src/components/Loader.jsx
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gold star for adding a loader! Render is kind of sleepy ⌛
Netlify link
Frontend
Backend
Collaborators
[FridaMari, JohannaBN]