T2836 - UI for assigning users to roles

@kuba-orlik how to add new user? at this moment is only admin. http method returns an error:

$ http --session=admin POST localhost:8080/api/v1/collections/users email=pz@wp.pl username=ziom password=secret
HTTP/1.1 401 Unauthorized
Connection: keep-alive
Content-Length: 88
Content-Type: application/json; charset=utf-8
Date: Mon, 22 Apr 2024 22:51:35 GMT
Keep-Alive: timeout=5

{
    "data": {},
    "message": "This method was not ran with a supercontext.",
    "type": "permission"
}

and how is it supposed to looks like? /admin/użytkownicy list of users, and what else? some form with input for writing roles? or distinct list of users roles? maybe form for role, or route for user roles?

The access policies for the users collection are set up so you cannot create a new account unless you have the SuperContext. There’s no way to directly gain supercontext through HTTP API. You can either temporarily change the create policy to Public (see https://hub.sealcode.org/source/aspazja/browse/master/src/back/collections/groups.ts$9-12 for an example of how to specify collection policies), or you can call the_app.collections.users.suCreate(...) in some route

going to /admin/użytkownicy shows you a list of users. Clicking on a user brings you to /admin/użytkownicy/:user_id/uprawnienia/ where you see a set of checkboxes (one per each available role). Submitting that latter form changes the set permissions.

You can get a list of available roles by calling app.ConfigManager.get("roles"). It only returns ["admin"] at the moment, but there will be more roles. You can test with more roles by adding

roles: ["admin", "test1", "test2"],

to config in src/back/app.ts :+1:

Accepted, updated to master and landed :flight_arrival: