Skip to content

Conversation

@wwenzz
Copy link

@wwenzz wwenzz commented May 24, 2024

Netlify link

Frontend: https://team-peace-auth.netlify.app
Backend: https://project-auth-lh3p.onrender.com

Collaborators

[maikanetaka, SofieFerrari]

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 working authentication with a cute frontend! Good job 🚀

Comment on lines +16 to +24
username: { type: String, unique: true, required: true, minLength: 8 },
email: {
type: String,
unique: true,
required: true,
match: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
},
password: { type: String, required: true },
accessToken: { type: String, default: () => bcrypt.genSaltSync() },
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice if all properties were formatted like the email one 😄

Comment on lines +63 to +84
app.post("/signup", async (req, res) => {
try {
const { username, email, password } = req.body;
const user = new User({
username,
email,
password: bcrypt.hashSync(password, 10),
});
await user.save();
res.status(201).json({ message: "Sign up successfully", success: true });
} catch (error) {
console.log(error.message);
res.status(400).json({
message: "Could not sign up.",
success: false,
error: error.message,
});
}
});

// Log-in
app.post("/login", 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.

Usually endpoints are named in plural nouns, after what they return or in this case create. So a name suggestion is: 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.

5 participants