Skip to content

Rebecca Noy (non working state)#87

Draft
extra-jalapenos wants to merge 36 commits intoboolean-uk:mainfrom
extra-jalapenos:freedom
Draft

Rebecca Noy (non working state)#87
extra-jalapenos wants to merge 36 commits intoboolean-uk:mainfrom
extra-jalapenos:freedom

Conversation

@extra-jalapenos
Copy link
Copy Markdown

No description provided.

const token = await generateToken(payload)
console.log(token)
res.status(200).json({
message: `logged in user ${username,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I did not know you could use injection with multiple variables!

const user = await createUserDb(req, res)
if (user) res.status(201).json({ success: `User ${username} created`})
} catch (error) {
if (error instanceof PrismaClientKnownRequestError) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice to see you narrowing down the error type

try {
return jwt.verify(webtoken, secret)
} catch (error) {
return false
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Better to actually let the error throw here (or throw your own custom error). Just returning false, you lose some of the error information. False tells us that the token wasn't valid, but it doesn't tell us why the token wasn't valid. Is it malformed? is it expired? etc

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.

3 participants