Skip to content

Auth exercise#25

Open
janauhrich wants to merge 6 commits intopce-uw-jscript400:masterfrom
janauhrich:master
Open

Auth exercise#25
janauhrich wants to merge 6 commits intopce-uw-jscript400:masterfrom
janauhrich:master

Conversation

@janauhrich
Copy link

No description provided.

Copy link
Collaborator

@bwreid bwreid left a comment

Choose a reason for hiding this comment

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

A couple routes were left undone, but overall great job!

const token = req.headers.authorization.split("Bearer ")[1];
const payload = jwot.verify(token, SECRET_KEY);
const requestor = await User.findOne({ _id: payload.id });
const requestorIsAdmin = requestor.admin === true ? true : false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just using requester.admin would have the same effect.

if (!user) throw new Error(`Account could not be found`);

user.admin = true;
user.save();
Copy link
Collaborator

Choose a reason for hiding this comment

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

You'll want this to be await user.save()

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