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.

Plugins

Login Plugin: Show log in, if not logged in, shot logout if logged in

Started by Pascal Mahlberg 9 years ago · 9 replies · 4307 views
9 years ago

Hey,

i'am building a login area. I'am using the standard login plugin.

But my problem is, if i'am not logged in, there should be a link like "login" and if i'am logged in, there should be a link like "logout".

I;ve added this snippet:

{% if config.plugins.login.enabled and grav.user.username %}
<li>{% include 'partials/login-status.html.twig' %}</li>
{% endif %}

and it shows me a logout link, but when i click it, it gives me this error:

"Forbidden You don't have permission to access on this server."

Also:

I added the page "register". But If i'am clicking on it, a white Page is showing without a registerformular.

Anny suggestions?

Thanks!

9 years ago

Also: If i direct to "login" and click on logg out there, it works. But if i click on logout in the navigation, it will not work.

9 years ago

Got some major-ish updates coming to Login plugin soon. I hope some of these will address the issues you are seeing. You can test with the current "develop" version in the Login github repo.

👍 1
8 years ago

@rhuk great work with the login.

I'm also looking for this functionality to have a link in the menu with the appropriate prompts login/register if user not logged in and hello user, logout according to the current state. Is there a standard way to do this now?

Note that I can see the Conditional "{{hello user name message}} Logout" when user logged in but not the "{{hello stranger message}} Login"

Thanks

last edited 03/20/18 by Nathan Argetsinger
7 years ago

Is this possible at this point with the login plugin, I would like to have this as well

7 years ago

Similar questions have been asked before. A search for "logged in menu" in this forum will give you a good overview of these.

6 years ago

Hi this one is still on my list and don't know how to achieve this. Can someone help me out?

My navigation template is

TWIG
<ul class="nav navbar-nav navbar-right ">
{% for page in pages.children.visible %}
{% set active_page = (page.active or page.activeChild) ? 'active' : '' %}
    <li>
        <a href="{{ page.url }}" class="{{ active_page }}">
            {{ page.menu }}
        </a>
    </li>
{% endfor %}

</ul>

I would like to have login and logout text in the menu (last item) based on status.

Thanks!

5 years ago

I did try adding this which works fine to show logout when loggedin

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 %}

But then i need to add an extra login link in the menu which should be invisible once logged in. Only available when anonymous. Not sure how to do that.

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 43 1 week ago
Plugins · by Xavier, 4 weeks ago
2 53 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1179 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 48 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 72 2 months ago