Skip to content

Commit

Permalink
Handle sudo connection in the account view
Browse files Browse the repository at this point in the history
Expand webadmin.views.my_account to also detect whether the current
context was created via sudo
If the current session was created with sudo, disable the ability to
update experimenter properties and password in the UI
  • Loading branch information
sbesson committed Nov 29, 2023
1 parent 604d527 commit 80e14e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions omeroweb/webadmin/templates/webadmin/myaccount.html
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@

{% if ldapAuth %}
<div id="password"><label>LDAP: </label>{{ ldapAuth }}</div>
{% else %}
{% elif not isSudo %}

<div id="password">

Expand All @@ -308,8 +308,9 @@
</div>
{% endif %}


{% if not isSudo %}
<input type="submit" value="{% trans 'Save' %}" />
{% endif %}
</div>
<div style="clear:both"></div>
</form>
Expand Down
2 changes: 2 additions & 0 deletions omeroweb/webadmin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,7 @@ def my_account(request, action=None, conn=None, **kwargs):
isLdapUser,
hasAvatar,
) = prepare_experimenter(conn)
isSudo = conn.getEventContext().sudoerId is not None
try:
defaultGroupId = defaultGroup.id
except Exception:
Expand Down Expand Up @@ -1092,6 +1093,7 @@ def my_account(request, action=None, conn=None, **kwargs):
context = {
"form": form,
"ldapAuth": isLdapUser,
"isSudo": isSudo,
"experimenter": experimenter,
"ownedGroups": ownedGroups,
"password_form": password_form,
Expand Down

0 comments on commit 80e14e3

Please sign in to comment.