]> git.0d.be Git - mandayejs.git/commitdiff
add local login support
authorFrédéric Péters <fpeters@entrouvert.com>
Sun, 22 Mar 2015 12:11:35 +0000 (13:11 +0100)
committerFrédéric Péters <fpeters@entrouvert.com>
Sun, 22 Mar 2015 17:03:24 +0000 (18:03 +0100)
mandayejs/settings.py
mandayejs/static/mandaye.css
mandayejs/templates/mandaye/panel.html
mandayejs/templates/mandaye/post-login.html [new file with mode: 0644]
mandayejs/templates/registration/login.html [new file with mode: 0644]
mandayejs/urls.py
mandayejs/views.py

index 00d710531cd6c1a4bac7d80b8560dfa2fb40bcf9..ef003250474b639cf9f134da04deaf1a4c1aaa29 100644 (file)
@@ -89,3 +89,5 @@ STATICFILES_DIRS = (
 TEMPLATE_DIRS = (
     os.path.join(BASE_DIR, 'mandayejs', 'templates'),
 )
 TEMPLATE_DIRS = (
     os.path.join(BASE_DIR, 'mandayejs', 'templates'),
 )
+
+LOGIN_REDIRECT_URL = 'post-login'
index ce42b7038851ae729e9da18d2c2a73f29f0fd44c..8afe252c1ef099277d3fcfd28f48fe4c40c5f65d 100644 (file)
@@ -3,3 +3,7 @@
   color: white;
   padding: 5px 0;
 }
   color: white;
   padding: 5px 0;
 }
+
+#mandaye-js a {
+  color: white;
+}
index 77b9721d18221fbada37d7af6e54eb14eb6c2274..03636efbc49ba61d16aa7f9bcb9d2ce5b76f4a62 100644 (file)
@@ -1,3 +1,7 @@
 <div>
 <div>
-hello world
+{% if user.is_authenticated %}
+  {{ user.username }} <a href="{% url 'auth_logout' %}">Logout</a>
+{% else %}
+  <a href="{% url 'auth_login' %}">Log in</a>
+{% endif %}
 </div>
 </div>
diff --git a/mandayejs/templates/mandaye/post-login.html b/mandayejs/templates/mandaye/post-login.html
new file mode 100644 (file)
index 0000000..012639e
--- /dev/null
@@ -0,0 +1,5 @@
+<html>
+<body>
+  post login
+</body>
+</html>
diff --git a/mandayejs/templates/registration/login.html b/mandayejs/templates/registration/login.html
new file mode 100644 (file)
index 0000000..ea78c5d
--- /dev/null
@@ -0,0 +1,9 @@
+<html>
+<body>
+<form method="post">
+{% csrf_token %}
+{{ form.as_p }}
+<input type="submit" value="Log in" />
+</form>
+</body>
+</html>
index 959c2d960b0dbff183d5b57fbd8d3c2fdc007ea8..73961cb7076c09b5be03543e240f272ea5e68537 100644 (file)
@@ -3,6 +3,9 @@ from django.contrib import admin
 
 urlpatterns = patterns('',
     url(r'^_mandaye/panel$', 'mandayejs.views.panel', name='panel'),
 
 urlpatterns = patterns('',
     url(r'^_mandaye/panel$', 'mandayejs.views.panel', name='panel'),
+    url(r'^_mandaye/login/$', 'mandayejs.views.login', name='auth_login'),
+    url(r'^_mandaye/logout/$', 'mandayejs.views.logout', name='auth_logout'),
+    url(r'^_mandaye/post-login/$', 'mandayejs.views.post_login', name='post-login'),
 
     url(r'^_mandaye/admin/', include(admin.site.urls)),
 )
 
     url(r'^_mandaye/admin/', include(admin.site.urls)),
 )
index 97d5fbe194618759ce0201d3c7738260eead28e2..7123067296eee4a177da4992ddd7bbe0bba0e632 100644 (file)
@@ -1,6 +1,24 @@
+from django.contrib.auth import views as auth_views
+from django.contrib.auth import logout as auth_logout
+from django.http import HttpResponseRedirect
 from django.views.generic.base import TemplateView
 
 from django.views.generic.base import TemplateView
 
+
+def login(request, *args, **kwargs):
+    return auth_views.login(request, *args, **kwargs)
+
+def logout(request, *args, **kwargs):
+    auth_logout(request)
+    return HttpResponseRedirect('/')
+
+
 class Panel(TemplateView):
     template_name = 'mandaye/panel.html'
 
 panel = Panel.as_view()
 class Panel(TemplateView):
     template_name = 'mandaye/panel.html'
 
 panel = Panel.as_view()
+
+
+class PostLogin(TemplateView):
+    template_name = 'mandaye/post-login.html'
+
+post_login = PostLogin.as_view()