Skip to content

Conversation

@Yaser-2004
Copy link

The csv file should be in the format:

  • first row should contain the headers --> name, email, role
  • then proceed with any data accordingly

const hashed_password: string = await bcrypt.hash(password, 10);

//Finding the role_id based on teamRole
const role = await Role.findOne({ name: MainWebsiteRole[teamRole] });
Copy link
Member

Choose a reason for hiding this comment

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

MainWebsiteRole and the Role in database are two different concepts.

MainWebsiteRole is basically the role visible to the general public on our main website
While Role is an internal thing which may vary dynamically.

This is required as suppose a person with designation (main website role) Developer can have different roles in the society, some may have the role of superuser, while other person may have some other role (say foo).

This helps to create different views, and permission levels according to the structure of society while putting people in the same team group.


Another example,

I'm one of the Coordinator of the society (main website role) but I've the role of Superuser, as superuser have the access to all the routes and endpoints required for technical maintenance.
Yet, another person may have the same designation (main website role) of Coordinator, yet have some lower level of permission, and hence a different role with less permission, say the role named Illustrator.


What can you do here?

Directly assume the parameter received is ObjectId of required role, and add that user accordingly.

In the frontend, you fetch all the available roles in the "Add User(s)" page, and give option to user in a dropdown menu to select users role.

For multiple users addition (via CSV), you can follow one of two approaches (or can come up with some other of your own as well)

  1. Frontend should read CSV and replace role name given with their ObjectId before sending the API request.
  2. Allow Backend to accept role with role name (string) and map strings back to role_id (ObjectId).

Preference: Follow the 1st approach, as it can help to detect error in CSV early.

Additional note for frontend part: Make sure user can download a "sample CSV" (with headers and maybe a dummy user entry), so making the CSV file is intuitive.

@dvishal485 dvishal485 marked this pull request as draft February 6, 2025 19:16
@dvishal485
Copy link
Member

The PR is not ready yet, consider getting it done. Let me know if there is some help required regarding this that I can offer.

@dtutimes/2025-team

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