fix: become/stop root should redirect to previous url

for default theme; butterball already did that
This commit is contained in:
Lance Edgar 2024-09-16 12:55:58 -05:00
parent 0b4efae392
commit 2308d2e240
2 changed files with 18 additions and 16 deletions

View file

@ -632,9 +632,23 @@
% endif % endif
<div class="navbar-dropdown"> <div class="navbar-dropdown">
% if request.is_root: % if request.is_root:
${h.link_to("Stop being root", url('stop_root'), class_='navbar-item root-user')} ${h.form(url('stop_root'), ref='stopBeingRootForm')}
${h.csrf_token(request)}
<input type="hidden" name="referrer" value="${request.current_route_url()}" />
<a @click="$refs.stopBeingRootForm.submit()"
class="navbar-item root-user">
Stop being root
</a>
${h.end_form()}
% elif request.is_admin: % elif request.is_admin:
${h.link_to("Become root", url('become_root'), class_='navbar-item root-user')} ${h.form(url('become_root'), ref='startBeingRootForm')}
${h.csrf_token(request)}
<input type="hidden" name="referrer" value="${request.current_route_url()}" />
<a @click="$refs.startBeingRootForm.submit()"
class="navbar-item root-user">
Become root
</a>
${h.end_form()}
% endif % endif
% if messaging_enabled: % if messaging_enabled:
${h.link_to("Messages{}".format(" ({})".format(inbox_count) if inbox_count else ''), url('messages.inbox'), class_='navbar-item')} ${h.link_to("Messages{}".format(" ({})".format(inbox_count) if inbox_count else ''), url('messages.inbox'), class_='navbar-item')}

View file

@ -909,7 +909,7 @@
${h.form(url('stop_root'), ref='stopBeingRootForm')} ${h.form(url('stop_root'), ref='stopBeingRootForm')}
${h.csrf_token(request)} ${h.csrf_token(request)}
<input type="hidden" name="referrer" value="${request.current_route_url()}" /> <input type="hidden" name="referrer" value="${request.current_route_url()}" />
<a @click="stopBeingRoot()" <a @click="$refs.stopBeingRootForm.submit()"
class="navbar-item has-background-danger has-text-white"> class="navbar-item has-background-danger has-text-white">
Stop being root Stop being root
</a> </a>
@ -918,7 +918,7 @@
${h.form(url('become_root'), ref='startBeingRootForm')} ${h.form(url('become_root'), ref='startBeingRootForm')}
${h.csrf_token(request)} ${h.csrf_token(request)}
<input type="hidden" name="referrer" value="${request.current_route_url()}" /> <input type="hidden" name="referrer" value="${request.current_route_url()}" />
<a @click="startBeingRoot()" <a @click="$refs.startBeingRootForm.submit()"
class="navbar-item has-background-danger has-text-white"> class="navbar-item has-background-danger has-text-white">
Become root Become root
</a> </a>
@ -1103,18 +1103,6 @@
const key = 'menu_' + hash + '_shown' const key = 'menu_' + hash + '_shown'
this[key] = !this[key] this[key] = !this[key]
}, },
% if request.is_admin:
startBeingRoot() {
this.$refs.startBeingRootForm.submit()
},
stopBeingRoot() {
this.$refs.stopBeingRootForm.submit()
},
% endif
}, },
} }