Skip to content
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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

gaidukev
Copy link

No description provided.

const User = require("../models/user.model");
const Authenticator = require("../services/Authenticator");
const OnRegisterTokenVerifier = require("../services/OnRegisterTokenVerifier");
const NewUserCreator = require("../services/NewUserCreator");
Copy link
Collaborator

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;
Copy link
Collaborator

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" });
}
};

Copy link
Collaborator

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);
Copy link
Collaborator

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

//////////////////////////
Copy link
Collaborator

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

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