Skip to content

Conversation

@Josephineoderland
Copy link

Copy link
Contributor

@HIPPIEKICK HIPPIEKICK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done 🔑 ⭐

@@ -0,0 +1,21 @@
import jwt from "jsonwebtoken"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun that you tried out jwt 👍

password: { type: String, required: true }
});

userSchema.pre('save', async function(next) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 })
}
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the thought behind this route? And how about security?

Comment on lines +33 to +34
console.log(username)
console.log(password)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove logs

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")
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just remember that even logs and comments should be in English

import Home from "./components/Home"
import { AuthProvider } from "./context/AuthContext"

function App() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, arrow function

return
}

console.log("User exists. Proceeding with login...")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alerts are enough, no need for logs


const authRouter = express.Router()

authRouter.post("/signup", async (req, res) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Endpoints are most often named nouns in plural, so instead of signup and login, it could be POST /users and POST /sessions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants