Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Log out issue (Front end user)

Started by Dean Bateman 8 years ago · 3 replies · 802 views
8 years ago

When I navigate to a private page, i am shown the login form as i would expect, this then shows me a login status in my nav (code below) once logged in

The button i am presented with states log out but it does not work, I do not know how to fix this can anyone help?

how can i log out a front end user?

i have inserted this code into my nav bar
{% if grav.user.username %}
<li><i class="fa fa-lock"></i> {% include 'partials/login-status.html.twig' %}</li>
{% endif %}

which will load this from the login plugin
<span class="login-status">
{% if grav.user.authenticated %}
<strong>{{ grav.user.fullname ?: grav.user.username }}</strong>, <a class="logout" href="{{ uri.addNonce((base_url_relative ~ uri.path)|trim('/') ~ '/task' ~ config.system.param_sep ~ 'login.logout', 'logout-form', 'logout-nonce')|e }}">{{ 'PLUGIN_LOGIN.BTN_LOGOUT'|t }}</a>
{% endif %}
</span>

and on my page i added
access:
site.ambassador: true
login:
visibility_requires_access: true

8 years ago

on further checking there is no href value on the link

<a class="logout" href="">Logout</a>

8 years ago

very weird, i changed themes it gave me a link on the href, it seems to be if i place it in the base template it works in my include nav templete it fails, it doesnt recognise config.plugins.login.enabled

8 years ago

OK finally found the fix / issue

TWIG
{% if config.plugins.login.enabled and grav.user.username %}

i was using this code to access the status and I placed this within the nav_loop macro and it would return config.plugins.login.enabled as null

once removed from the macro and placed outside of this loop the config.plugins.login.enabled is accessible

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 82 12 hours ago
General · by pamtbaau, 17 hours ago
1 55 16 hours ago
General · by Andy Miller, 1 day ago
0 45 1 day ago
General · by Marcel, 12 months ago
6 348 5 days ago
General · by Duc , 5 days ago
3 43 5 days ago