mirror of
https://github.com/YunoHost/apps.git
synced 2024-09-03 20:06:07 +02:00
appstore: add usermenu with logout option
This commit is contained in:
parent
038af2cc42
commit
abc1d038f1
2 changed files with 60 additions and 23 deletions
16
store/app.py
16
store/app.py
|
@ -284,6 +284,22 @@ def sso_login_callback():
|
||||||
@app.route('/logout')
|
@app.route('/logout')
|
||||||
def logout():
|
def logout():
|
||||||
session.clear()
|
session.clear()
|
||||||
|
|
||||||
|
# Only use the current referer URI if it's on the same domain as the current route
|
||||||
|
# to avoid XSS or whatever...
|
||||||
|
referer = request.environ.get("HTTP_REFERER")
|
||||||
|
if referer:
|
||||||
|
if referer.startswith("http://"):
|
||||||
|
referer = referer[len("http://"):]
|
||||||
|
if referer.startswith("https://"):
|
||||||
|
referer = referer[len("https://"):]
|
||||||
|
if "/" not in referer:
|
||||||
|
referer = referer + "/"
|
||||||
|
|
||||||
|
domain, uri = referer.split("/", 1)
|
||||||
|
if domain == request.environ.get("HTTP_HOST"):
|
||||||
|
return redirect("/" + uri)
|
||||||
|
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -91,30 +91,42 @@
|
||||||
{{ _("Login using YunoHost's forum") }}
|
{{ _("Login using YunoHost's forum") }}
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<button
|
<div class="relative">
|
||||||
type="button"
|
<button
|
||||||
class="group flex shrink-0 items-center rounded-lg transition"
|
id="toggleUserMenu"
|
||||||
>
|
type="button"
|
||||||
<span class="sr-only">{{ _("Menu") }}</span>
|
class="group flex shrink-0 items-center rounded-lg transition"
|
||||||
<img
|
>
|
||||||
alt="Man"
|
<img
|
||||||
src="{{ user['avatar_url'] }}"
|
alt="Man"
|
||||||
class="h-10 w-10 rounded-full object-cover"
|
src="{{ user['avatar_url'] }}"
|
||||||
/>
|
class="h-10 w-10 rounded-full object-cover"
|
||||||
<p class="ms-2 hidden text-left text-xs sm:inline-block">
|
/>
|
||||||
<strong class="block font-medium">{{ user['username'] }}</strong>
|
<p class="ms-2 hidden text-left text-xs sm:inline-block">
|
||||||
</p>
|
<strong class="block font-medium">{{ user['username'] }}</strong>
|
||||||
<i class="fa fa-caret-down fa-fw" aria-hidden="true"></i>
|
</p>
|
||||||
</button>
|
<i class="fa fa-caret-down fa-fw" aria-hidden="true"></i>
|
||||||
<!--
|
</button>
|
||||||
<a
|
<div
|
||||||
class="block rounded-md bg-teal-600 px-5 py-2.5 text-sm font-medium text-white transition hover:bg-teal-700"
|
id="userMenu"
|
||||||
href="{{ url_for('logout') }}"
|
class="hidden absolute end-0 z-10 mt-2 w-56 rounded-md border border-gray-100 bg-white shadow-lg"
|
||||||
>
|
role="menu"
|
||||||
Logout
|
>
|
||||||
</a>
|
<div class="p-2">
|
||||||
-->
|
<a
|
||||||
|
href="/logout"
|
||||||
|
class="block rounded-lg px-4 py-2 text-sm text-gray-500 hover:bg-gray-50 hover:text-gray-700"
|
||||||
|
role="menuitem"
|
||||||
|
>
|
||||||
|
Logout
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
@ -134,4 +146,13 @@
|
||||||
<footer class="h-5 mt-5"></footer>
|
<footer class="h-5 mt-5"></footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
{% if user %}
|
||||||
|
<script>
|
||||||
|
let toggleUserMenu = document.getElementById('toggleUserMenu');
|
||||||
|
toggleUserMenu.addEventListener('click', () => {
|
||||||
|
document.getElementById('userMenu').classList.toggle("hidden");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Reference in a new issue