Skip to content

Callum#91

Open
Callumhayden99 wants to merge 3 commits intoboolean-uk:mainfrom
Callumhayden99:main
Open

Callum#91
Callumhayden99 wants to merge 3 commits intoboolean-uk:mainfrom
Callumhayden99:main

Conversation

@Callumhayden99
Copy link
Copy Markdown

No description provided.

Comment thread src/client/App.jsx

const handleRegister = async ({ username, password }) => {
try {
const response = await fetch(`http://localhost:4000/user/register`, {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As you're making multiple post requests it would be good if you made a helper function so that you don't have to keep creating the objects object/duplicate the request code

const prisma = new PrismaClient();

const jwtSecret = 'mysecret';
const jwtSecret = "mysecret";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

jwt secrets are usually best kept in the .env file

return res.status(401).json({ error: 'Invalid username or password.' });
if (passwordsMatch) {
const token = jwt.sign({ username: foundUser.username }, jwtSecret, {
expiresIn: "24h",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expiresIn is also a good candidate for an environment variable so that we don't have to change code to change how long a token exists for.

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