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

Created privated area and page but cannot log out a user

Started by Dean Bateman 8 years ago · 0 replies · 768 views
8 years ago

I have created a page and have added this to the front matter

YAML
access:
    site.editor: true
login:
  visibility_requires_access: true

this allows my page to be displayed and accessed if I log in as an editor (group/user)

this works great,

next, I added to display login status, this doesn't display anything unless I removed config.plugins.login.enabled - it seems like this is not an option for login, I have the admin plugin install with the login

TWIG
{% if config.plugins.login.enabled and grav.user.username %}
  <li><i class="fa fa-lock"></i> {% include 'partials/login-status.html.twig' %}</li>
{% endif %}

so with config.plugins.login.enabled removed I can see the lock and user in my nav bar which is created from this code.

TWIG
<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>

but this does not create a href value

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

so my question is how do I call/create a link to logout a login user?

further to this if i do delete the user cookie i can log them out

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Mathieu Lecouturier, 6 days ago
3 130 3 days ago
Plugins · by Slebeig, 4 weeks ago
1 296 4 weeks ago
Plugins · by Rene, 2 months ago
2 455 2 months ago
Plugins · by Xavier, 2 months ago
2 373 2 months ago
Plugins · by Luka Prinčič, 7 years ago
3 1596 2 months ago