-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Passport.js Local Strategy #696
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.github/workflows/issue-metrics.yml
Outdated
@@ -8,35 +8,35 @@ on: | |||
pull_request: | |||
types: [opened] | |||
branches: | |||
- main | |||
- main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The oldest comment in the book: Rebase to remove these 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait were they literally the oldest comments in the codebase? lol! Rebased ✅
server/auth/config/passport.js
Outdated
}, | ||
async (email, password, done) => { | ||
try { | ||
const user = await User.findOne({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will have to update this config to use Admin
s. For password validation, check out server/lib/encrypt
after you rebase this. That will have the methods you need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the Admin
model exists and has been implemented, the mock User model has been removed and config updated. Password validation now being handled by the code in server/lib/encrypt
server/auth/config/passport.js
Outdated
}) | ||
passport.deserializeUser(async (id, done) => { | ||
try { | ||
const user = await User.findByPk(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just use Admin.query().findById()
now.
https://vincit.github.io/objection.js/api/query-builder/find-methods.html#findbyid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaned up this code to use .query().findById(id)
instead of .findByPk(id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All changes addressed 👍
.github/workflows/issue-metrics.yml
Outdated
@@ -8,35 +8,35 @@ on: | |||
pull_request: | |||
types: [opened] | |||
branches: | |||
- main | |||
- main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait were they literally the oldest comments in the codebase? lol! Rebased ✅
server/auth/config/passport.js
Outdated
}, | ||
async (email, password, done) => { | ||
try { | ||
const user = await User.findOne({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the Admin
model exists and has been implemented, the mock User model has been removed and config updated. Password validation now being handled by the code in server/lib/encrypt
server/auth/config/passport.js
Outdated
}) | ||
passport.deserializeUser(async (id, done) => { | ||
try { | ||
const user = await User.findByPk(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaned up this code to use .query().findById(id)
instead of .findByPk(id)
83d2c7f
to
46a3bb4
Compare
As for your first question, I agree that we should merge these couple branches into 1 since it originally was 1 Issue, but we broke it down with Konny to work on it separately. |
46a3bb4
to
57d99e0
Compare
This commit integrates Passport's Local Strategy for user authentication. The strategy has been set up to use email as the username field. If the email is not found or the password is incorrect, error messages are returned. Co-authored-by: KonnyGuo [email protected] Implement Passport.js Local Strategy This is the second increment after changes were requested in the review. This commit integrates Passport's Local Strategy for user authentication. The strategy has been set up to use email as the username field. If the email is not found or the password is incorrect, error messages are returned. Co-authored-by: KonnyGuo [email protected] Revised Implementation of Passport.js Local Strategy This is the second increment after changes were requested in the review. This commit integrates Passport's Local Strategy for user authentication. The strategy has been set up to use email as the username field. If the email is not found or the password is incorrect, error messages are returned. Co-authored-by: KonnyGuo [email protected]
57d99e0
to
d1745c3
Compare
This commit for #617 integrates Passport's Local Strategy for user authentication.
The strategy has been set up to use email as the username field. If the email is not found or the password is incorrect, error messages are returned.
Was not sure how to implement tests on Users because users do not exist yet.
Co-authored-by: KonnyGuo [email protected]