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

Accessing User Roles #447

Open
braughtg opened this issue Apr 22, 2022 · 3 comments · May be fixed by #690
Open

Accessing User Roles #447

braughtg opened this issue Apr 22, 2022 · 3 comments · May be fixed by #690
Labels
new feature A new user visible feature to be added

Comments

@braughtg
Copy link
Member

When creating and displaying UI elements it will be necessary to know what roles a user has in the FarmOS system (e.g. Admin, Farm Manager, Farm Worker, Farm Viewer). This will allow the UI to display only the controls that the current user has permission to use (e.g. Edit / Delete).

@braughtg braughtg added the new feature A new user visible feature to be added label Apr 22, 2022
@braughtg
Copy link
Member Author

braughtg commented Apr 22, 2022

One way to address this is to add an additional variable to all pages that indicates the roles that the current user has. The current variables can be seen on the page: http://localhost/farm/fd2-example/vars. Currently, the UserID and the UserName are available. A list of UserRoles could also be added. The current variables are generated in all of the .module files. For the above example tab they are defined in: farmdata2_modules/fd2_tabs/fd2_example/fd2_example.module. It should be possible to access the user roles in the .module file and add similar code to add a JavaScript variable accessible in the page.

If this is done, the same variable should be added in the .module files for all of the tabs (FD2 Example, FieldKit, BarnKit, FD2 School).

In addition, some central way of representing what the different roles are able to do will be important to prevent duplication of that information and effort in each page.

@braughtg
Copy link
Member Author

Another possibility here would be to determine if the configuration information in FarmOS/Drupal is accessible via API. For example, when logged in as an Admin, it is possible to see and configure permissions on the "Modules" page. Under the "Farm API" the "Permissions" can be configures to allow or not allow all of the possible operations for each role (e.g. delete logs, delete own logs, etc). If these can be accessed via API then pages could use this information to configure the UI rather than the role. That would significantly reduce the duplication of information.

@nguyenbanhducA1K51
Copy link
Contributor

I would like to work on this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new user visible feature to be added
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants