-
Notifications
You must be signed in to change notification settings - Fork 0
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
Wrote tests & endpoint for change password #106
base: develop
Are you sure you want to change the base?
Conversation
const User = require("../models/user.model"); | ||
const Authenticator = require("../services/Authenticator"); | ||
const OnRegisterTokenVerifier = require("../services/OnRegisterTokenVerifier"); | ||
const NewUserCreator = require("../services/NewUserCreator"); |
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 don't want to include code formatting changes in PR. If you are using a code formatting tool then add this file to its .ignore
const token = req.body.token; | ||
const username = req.body.username; | ||
const role = req.body.role; | ||
const token = req.body.token; |
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.
do not include whitespace changes
return res.status(400).json({ message: "Invalid username or role" }); | ||
} | ||
}; | ||
|
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.
do not include formatting changes
|
||
router.route("/auth/change_password").post(userController.change_password); |
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.
Only a user who is authenticated can change their password. This means they should have a valid jwt token and we should verify it before changing password. Check this file to see what this function would look like: https://github.com/UofA-Blueprint/AlzheimerCalgary/blob/develop/server/services/OnRegisterTokenVerifier.js
You would want to make a general case function similar to the above. Then call this verifier function before calling changePassword
////////////////////////// |
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.
get rid of whitespace changes
No description provided.