Skip to content

Add role to User.create method in signup function #203

Open
@lexliu19

Description

@lexliu19

In Authorization: User Roles and Permissions chapter, we need to add role: req.body.role, to signup function, otherwise, the user role will always be default "user" and never updated to req.body.role

exports.signup = catchAsyncError(async (req, res, next) => {
  const newUser = await User.create({
    name: req.body.name,
    email: req.body.email,
    password: req.body.password,
    passwordConfirm: req.body.passwordConfirm,
    role: req.body.role,
  });
....
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions