You've already forked snikket-web-portal
Compare commits
8 Commits
fix/invite
...
fix/role-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcfcdbeb23 | ||
|
|
fd566b7f30 | ||
|
|
2762304ae8 | ||
|
|
49bbc3ab09 | ||
|
|
8f1f80b7d7 | ||
|
|
13bc283a3e | ||
|
|
abc0af3918 | ||
|
|
0aff4fc99d |
@@ -1,6 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
export SNIKKET_WEB_DOMAIN="$SNIKKET_DOMAIN"
|
export SNIKKET_WEB_DOMAIN="$SNIKKET_DOMAIN"
|
||||||
|
if [ -n "${SNIKKET_SITE_NAME:-}" ]; then
|
||||||
|
export SNIKKET_WEB_SITE_NAME="$SNIKKET_SITE_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
export SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_INTERFACE="${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_INTERFACE-127.0.0.1}"
|
export SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_INTERFACE="${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_INTERFACE-127.0.0.1}"
|
||||||
export SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT="${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT-5765}"
|
export SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT="${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT-5765}"
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class EditUserForm(BaseForm):
|
|||||||
_l("Access Level"),
|
_l("Access Level"),
|
||||||
choices=[
|
choices=[
|
||||||
("prosody:restricted", _("Limited")),
|
("prosody:restricted", _("Limited")),
|
||||||
("prosody:normal", _l("Normal user")),
|
("prosody:user", _l("Normal user")),
|
||||||
("prosody:admin", _l("Administrator")),
|
("prosody:admin", _l("Administrator")),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@@ -116,7 +116,7 @@ async def edit_user(localpart: str) -> typing.Union[werkzeug.Response, str]:
|
|||||||
await client.update_user(
|
await client.update_user(
|
||||||
localpart,
|
localpart,
|
||||||
display_name=form.display_name.data,
|
display_name=form.display_name.data,
|
||||||
roles=[form.role.data],
|
role=form.role.data,
|
||||||
)
|
)
|
||||||
|
|
||||||
await flash(
|
await flash(
|
||||||
@@ -131,7 +131,7 @@ async def edit_user(localpart: str) -> typing.Union[werkzeug.Response, str]:
|
|||||||
if target_user_info.roles:
|
if target_user_info.roles:
|
||||||
form.role.data = target_user_info.roles[0]
|
form.role.data = target_user_info.roles[0]
|
||||||
else:
|
else:
|
||||||
form.role.data = "prosody:normal"
|
form.role.data = "prosody:user"
|
||||||
|
|
||||||
return await render_template(
|
return await render_template(
|
||||||
"admin_edit_user.html",
|
"admin_edit_user.html",
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ from . import xmpputil
|
|||||||
from .xmpputil import split_jid
|
from .xmpputil import split_jid
|
||||||
|
|
||||||
|
|
||||||
SCOPE_DEFAULT = "prosody:scope:default"
|
SCOPE_DEFAULT = "prosody:user"
|
||||||
SCOPE_ADMIN = "prosody:scope:admin"
|
SCOPE_ADMIN = "prosody:admin"
|
||||||
|
|
||||||
|
|
||||||
T = typing.TypeVar("T")
|
T = typing.TypeVar("T")
|
||||||
@@ -61,12 +61,18 @@ class AdminUserInfo:
|
|||||||
cls,
|
cls,
|
||||||
data: typing.Mapping[str, typing.Any],
|
data: typing.Mapping[str, typing.Any],
|
||||||
) -> "AdminUserInfo":
|
) -> "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(
|
return cls(
|
||||||
localpart=data["username"],
|
localpart=data["username"],
|
||||||
display_name=data.get("display_name") or None,
|
display_name=data.get("display_name") or None,
|
||||||
email=data.get("email") or None,
|
email=data.get("email") or None,
|
||||||
phone=data.get("phone") or None,
|
phone=data.get("phone") or None,
|
||||||
roles=data.get("roles"),
|
roles=roles,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -879,7 +885,7 @@ class ProsodyClient:
|
|||||||
localpart: str,
|
localpart: str,
|
||||||
*,
|
*,
|
||||||
display_name: typing.Optional[str],
|
display_name: typing.Optional[str],
|
||||||
roles: typing.Optional[typing.Collection[str]],
|
role: typing.Optional[str],
|
||||||
session: aiohttp.ClientSession,
|
session: aiohttp.ClientSession,
|
||||||
) -> None:
|
) -> None:
|
||||||
payload: typing.Dict[str, typing.Any] = {
|
payload: typing.Dict[str, typing.Any] = {
|
||||||
@@ -887,8 +893,8 @@ class ProsodyClient:
|
|||||||
}
|
}
|
||||||
if display_name is not None:
|
if display_name is not None:
|
||||||
payload["display_name"] = display_name
|
payload["display_name"] = display_name
|
||||||
if roles is not None:
|
if role is not None:
|
||||||
payload["roles"] = list(roles)
|
payload["role"] = role
|
||||||
|
|
||||||
async with session.put(
|
async with session.put(
|
||||||
self._admin_v1_endpoint("/users/{}".format(localpart)),
|
self._admin_v1_endpoint("/users/{}".format(localpart)),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
{% macro access_level_description(role, caller=None) %}
|
{% macro access_level_description(role, caller=None) %}
|
||||||
{%- if role == "prosody:restricted" -%}
|
{%- if role == "prosody:restricted" -%}
|
||||||
{% trans %}Limited users can interact with users on the same Snikket service and be members of circles.{% endtrans %}
|
{% 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 %}
|
{% trans %}Like limited users and can also interact with users on other Snikket services.{% endtrans %}
|
||||||
{%- elif role == "prosody:admin" -%}
|
{%- elif role == "prosody:admin" -%}
|
||||||
{% trans %}Like normal users and can access the admin panel in the web portal.{% endtrans %}
|
{% trans %}Like normal users and can access the admin panel in the web portal.{% endtrans %}
|
||||||
|
|||||||
Reference in New Issue
Block a user