Open
Conversation
HIPPIEKICK
approved these changes
May 27, 2024
| @@ -0,0 +1,21 @@ | |||
| import jwt from "jsonwebtoken" | |||
Contributor
There was a problem hiding this comment.
Fun that you tried out jwt 👍
| password: { type: String, required: true } | ||
| }); | ||
|
|
||
| userSchema.pre('save', async function(next) { |
Contributor
There was a problem hiding this comment.
In your routes you're using arrow functions, try to be consistent with that throughout the whole code base
Comment on lines
+21
to
+28
| authRouter.get("/signup", async (req, res) => { | ||
| try { | ||
| const users = await User.find() | ||
| res.status(200).json(users) | ||
| } catch (error) { | ||
| res.status(500).json({ error: error.message }) | ||
| } | ||
| }) |
Contributor
There was a problem hiding this comment.
What's the thought behind this route? And how about security?
Comment on lines
+33
to
+34
| console.log(username) | ||
| console.log(password) |
Comment on lines
+18
to
+22
| const db = mongoose.connection | ||
| db.on("error", console.error.bind(console, "Anslutningsfel:")) | ||
| db.once("open", () => { | ||
| console.log("Ansluten till databasen") | ||
| }) |
Contributor
There was a problem hiding this comment.
Nice! Just remember that even logs and comments should be in English
| import Home from "./components/Home" | ||
| import { AuthProvider } from "./context/AuthContext" | ||
|
|
||
| function App() { |
Contributor
There was a problem hiding this comment.
Same here, arrow function
| return | ||
| } | ||
|
|
||
| console.log("User exists. Proceeding with login...") |
Contributor
There was a problem hiding this comment.
Alerts are enough, no need for logs
|
|
||
| const authRouter = express.Router() | ||
|
|
||
| authRouter.post("/signup", async (req, res) => { |
Contributor
There was a problem hiding this comment.
Endpoints are most often named nouns in plural, so instead of signup and login, it could be POST /users and POST /sessions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Netlify link
https://master--radiant-lollipop-9f6f69.netlify.app
https://project-auth-7ju7.onrender.com