From 8894827cd675e42b0be71eb3a03c9403d8a7377a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Dor=C5=88=C3=A1k?= Date: Mon, 4 May 2015 14:33:56 +0200 Subject: [PATCH] add FAS login relates to #7 --- fedora_software/settings.py | 33 +++++++++++++++++++++++------ fedora_software/templates/base.html | 8 +++++++ fedora_software/urls.py | 1 + 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/fedora_software/settings.py b/fedora_software/settings.py index 2574f63..9f47070 100644 --- a/fedora_software/settings.py +++ b/fedora_software/settings.py @@ -41,24 +41,35 @@ INSTALLED_APPS = ( #'django.contrib.admin', - #'django.contrib.auth', - #'django.contrib.contenttypes', - #'django.contrib.sessions', - #'django.contrib.messages', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', 'django.contrib.staticfiles', 'fedora_software', ) MIDDLEWARE_CLASSES = ( - #'django.contrib.sessions.middleware.SessionMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', - #'django.contrib.auth.middleware.AuthenticationMiddleware', - #'django.contrib.messages.middleware.MessageMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.locale.LocaleMiddleware', ) +TEMPLATE_CONTEXT_PROCESSORS = ( + 'django.contrib.auth.context_processors.auth', + 'django.core.context_processors.debug', + 'django.core.context_processors.i18n', + 'django.core.context_processors.media', + 'django.core.context_processors.static', + 'django.core.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + 'django.core.context_processors.request', +) + ROOT_URLCONF = 'fedora_software.urls' WSGI_APPLICATION = 'fedora_software.wsgi.application' @@ -129,6 +140,14 @@ }, } +AUTHENTICATION_BACKENDS = ( + 'fas.backend.FasBackend', +) + +LOGIN_URL = '/login/' +LOGOUT_URL = '/logout/' +LOGIN_REDIRECT_URL = '/' + FS_HIGHLIGHT_APPS = [ 'shotwell.desktop', 'datovka.desktop', diff --git a/fedora_software/templates/base.html b/fedora_software/templates/base.html index 8e8336d..8005a0b 100644 --- a/fedora_software/templates/base.html +++ b/fedora_software/templates/base.html @@ -55,6 +55,14 @@ +
  • + {% if request.user.is_authenticated %} + {{ request.user.first_name }} {{ request.user.last_name }} + - Log out + {% else %} + Log in + {% endif %} +
  • diff --git a/fedora_software/urls.py b/fedora_software/urls.py index 575b426..9537ccf 100644 --- a/fedora_software/urls.py +++ b/fedora_software/urls.py @@ -13,4 +13,5 @@ url(r'^category/(?P.*)$', CategoryView.as_view(), name='category'), url(r'^faq$', FaqView.as_view(), name='faq'), url(r'^i18n/', include('django.conf.urls.i18n')), + url('', include('fas.urls')), )