Browse Source

fix navbar showing user info even when not logged in

Nick Sweeting 4 years ago
parent
commit
4b098bea15
1 changed files with 14 additions and 10 deletions
  1. 14 10
      archivebox/templates/core/navigation.html

+ 14 - 10
archivebox/templates/core/navigation.html

@@ -9,14 +9,18 @@
     <a href="{% url 'public-index' %}">Public</a> | 
     <a href="{% url 'public-index' %}">Public</a> | 
     <a href="/admin/">Admin</a>
     <a href="/admin/">Admin</a>
      &nbsp; &nbsp;
      &nbsp; &nbsp;
-    {% block welcome-msg %}
-        {% trans 'User' %}
-        <strong>{% firstof user.get_short_name user.get_username %}</strong> &nbsp; &nbsp;
-    {% endblock %}
-    {% block userlinks %}
-        {% if user.has_usable_password %}
-            <a href="{% url 'admin:password_change' %}">Account</a> /
-        {% endif %}
-        <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
-    {% endblock %}
+    {% if user.is_authenticated %}
+        {% block welcome-msg %}
+            {% trans 'User' %}
+            <strong>{% firstof user.get_short_name user.get_username %}</strong> &nbsp; &nbsp;
+        {% endblock %}
+        {% block userlinks %}
+            {% if user.has_usable_password %}
+                <a href="{% url 'admin:password_change' %}">Account</a> /
+            {% endif %}
+            <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
+        {% endblock %}
+    {% else %}
+        <a href="{% url 'admin:login' %}">{% trans 'Log in' %}</a>
+    {% endif %}
 </div>
 </div>