Compare commits

...

6 Commits

Author SHA1 Message Date
Jonas Schäfer
fcfcdbeb23 Follow new role scheme in Prosody
Prosody changed its role scheme to only support a single primary role
for each user. In addition, the names of the built-in roles have been
changed. We thus follow those changes to be compatible with the most
recent trunk.

One open question is whether we should switch admin -> operator here,
too (operator being a server-wide admin), but so far there's no need
to.
2023-03-29 18:42:53 +02:00
Jonas Schäfer
fd566b7f30 Merge pull request #151 from snikket-im/fix/user-listing-roles
Make AdminUserInfo compatible with new API
2023-03-28 22:23:06 +02:00
Jonas Schäfer
2762304ae8 Make AdminUserInfo compatible with new API
The mod_http_admin_api changed recently [1], so we need to follow
suit.

Fixes #149.

   [1]: https://hg.prosody.im/prosody-modules/rev/d68348323406
2023-03-28 22:21:07 +02:00
Jonas Schäfer
49bbc3ab09 Merge pull request #148 from Zash/newscopes
Update to match new Prosody scope naming scheme
2023-03-28 21:42:00 +02:00
Kim Alvefur
8f1f80b7d7 Update to match new Prosody scope naming scheme
Ref https://hg.prosody.im/prosody-modules/rev/5ab134b7e510

Thanks Jonas
2023-03-28 21:14:20 +02:00
Jonas Schäfer
13bc283a3e Merge pull request #140 from snikket-im/feature/site-name-consistency
entrypoint: default SNIKKET_WEB_SITE_NAME to SNIKKET_SITE_NAME
2023-03-28 20:59:17 +02:00
3 changed files with 16 additions and 10 deletions

View File

@@ -77,7 +77,7 @@ class EditUserForm(BaseForm):
_l("Access Level"),
choices=[
("prosody:restricted", _("Limited")),
("prosody:normal", _l("Normal user")),
("prosody:user", _l("Normal user")),
("prosody:admin", _l("Administrator")),
],
)
@@ -116,7 +116,7 @@ async def edit_user(localpart: str) -> typing.Union[werkzeug.Response, str]:
await client.update_user(
localpart,
display_name=form.display_name.data,
roles=[form.role.data],
role=form.role.data,
)
await flash(
@@ -131,7 +131,7 @@ async def edit_user(localpart: str) -> typing.Union[werkzeug.Response, str]:
if target_user_info.roles:
form.role.data = target_user_info.roles[0]
else:
form.role.data = "prosody:normal"
form.role.data = "prosody:user"
return await render_template(
"admin_edit_user.html",

View File

@@ -27,8 +27,8 @@ from . import xmpputil
from .xmpputil import split_jid
SCOPE_DEFAULT = "prosody:scope:default"
SCOPE_ADMIN = "prosody:scope:admin"
SCOPE_DEFAULT = "prosody:user"
SCOPE_ADMIN = "prosody:admin"
T = typing.TypeVar("T")
@@ -61,12 +61,18 @@ class AdminUserInfo:
cls,
data: typing.Mapping[str, typing.Any],
) -> "AdminUserInfo":
try:
roles: typing.Optional[typing.List[str]] = [data["role"]]
assert roles is not None # make mypy happy
roles.extend(data.get("secondary_roles", []))
except KeyError:
roles = data.get("roles")
return cls(
localpart=data["username"],
display_name=data.get("display_name") or None,
email=data.get("email") or None,
phone=data.get("phone") or None,
roles=data.get("roles"),
roles=roles,
)
@@ -879,7 +885,7 @@ class ProsodyClient:
localpart: str,
*,
display_name: typing.Optional[str],
roles: typing.Optional[typing.Collection[str]],
role: typing.Optional[str],
session: aiohttp.ClientSession,
) -> None:
payload: typing.Dict[str, typing.Any] = {
@@ -887,8 +893,8 @@ class ProsodyClient:
}
if display_name is not None:
payload["display_name"] = display_name
if roles is not None:
payload["roles"] = list(roles)
if role is not None:
payload["role"] = role
async with session.put(
self._admin_v1_endpoint("/users/{}".format(localpart)),

View File

@@ -3,7 +3,7 @@
{% macro access_level_description(role, caller=None) %}
{%- if role == "prosody:restricted" -%}
{% trans %}Limited users can interact with users on the same Snikket service and be members of circles.{% endtrans %}
{%- elif role == "prosody:normal" -%}
{%- elif role == "prosody:user" -%}
{% trans %}Like limited users and can also interact with users on other Snikket services.{% endtrans %}
{%- elif role == "prosody:admin" -%}
{% trans %}Like normal users and can access the admin panel in the web portal.{% endtrans %}