Commit 7f15b0c1 authored by Daniel W Bond's avatar Daniel W Bond

merged auth and allauth

parents bf45cf29 e437637a
......@@ -43,3 +43,5 @@ coverage.xml
docs/_build/
# PyBuilder
target/
# Vim files
*.sw*
......@@ -4,7 +4,7 @@ django-allauth==0.19.0
django-autoslug==1.7.2
django-braces==1.4.0
django-crispy-forms==1.4.0
django-gmucas==2.1.1
git+https://github.com/the-ben-waters/django-cas.git
django-gravatar2==1.1.4
django-localflavor==1.0
django-model-utils==2.2
......
from django.contrib.auth.models import User
from django.conf import settings
def create_user(tree):
username = tree[0][0].text
user, user_created = User.objects.get_or_create(username=username)
if user_created:
user.email = "%s@%s" % (username, settings.ORGANIZATION_EMAIL_DOMAIN)
user.save()
print("Created user %s!" % username)
......@@ -2,15 +2,8 @@ from django.conf.urls import patterns, include, url
from accounts.views import DetailStudent, CreateStudent, DetailStudentSettings, DetailCurrentStudent, DetailCurrentStudentSettings
from accounts.models import Student
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# login and logout
url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login'),
#url(r'^logout/$', 'django.contrib.auth.views.logout', {'template_name': 'index.html'}, name='logout'),
url(r'', include('allauth.urls')),
url(r'^student/(?P<slug>[\w-]+)/$',
......
"""
Django settings for django_project project.
Django settings for roomlist project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
ORGANIZATION_EMAIL_DOMAIN = 'masonlive.gmu.edu'
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
os.path.join(BASE_DIR, 'housing/templates'),
......@@ -39,12 +41,11 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.static',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
'allauth.account.context_processors.account',
'allauth.socialaccount.context_processors.socialaccount',
#'allauth.account.context_processors.account',
#'allauth.socialaccount.context_processors.socialaccount',
)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'fGTL0pyk8MRq9YLXIOzFKZlneTdg3etdRxXs1FN2FqlVk595Ix'
......@@ -84,10 +85,13 @@ INSTALLED_APPS = (
CRISPY_TEMPLATE_PACK = 'bootstrap'
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'cas.middleware.CASMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
......@@ -98,7 +102,7 @@ WSGI_APPLICATION = 'settings.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {
'default': {
......@@ -112,7 +116,7 @@ DATABASES = {
}
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'en-us'
......@@ -124,18 +128,22 @@ USE_L10N = True
USE_TZ = True
SITE_ID = 2
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
ACCOUNT_ADAPTER = 'accounts.adapter.AccountAdapter'
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
"django.contrib.auth.backends.ModelBackend",
# `allauth` specific authentication methods, such as login by e-mail
"allauth.account.auth_backends.AuthenticationBackend",
'django.contrib.auth.backends.ModelBackend',
'cas.backends.CASBackend',
)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
CAS_SERVER_URL = 'https://login.gmu.edu'
CAS_LOGOUT_COMPLETELY = True
CAS_PROVIDE_URL_TO_LOGOUT = True
STATIC_URL = '/static/'
CAS_RESPONSE_CALLBACKS = (
'accounts.cas_callbacks.create_user',
)
......@@ -2,6 +2,7 @@ from django.conf.urls import patterns, include, url
from django.views.generic import TemplateView
from django.contrib import admin
admin.autodiscover()
handle404 = TemplateView.as_view(template_name="404.html")
......@@ -18,6 +19,10 @@ urlpatterns = patterns('',
url(r'^housing/', include('housing.urls')),
url(r'^accounts/', include('accounts.urls')),
# login and logout
url(r'^login/$', 'cas.views.login', name='login'),
url(r'^logout/$', 'cas.views.logout', name='logout'),
# alternate interfaces
url(r'^api/', include('api.urls')),
url(r'^admin/', include(admin.site.urls)),
......
......@@ -22,10 +22,10 @@
{% if user.is_authenticated %}
<li><a href="/accounts/student/{{ user.username }}">{{ user.username }}</a>
</li>
<li><a href="/accounts/logout/">Logout</a>
<li><a href="{% url 'logout' %}">Logout</a>
</li>
{% else %}
<li><a href="/accounts/login/">Login</a>
<li><a href="{% url 'login' %}">Login</a>
</li>
{% endif %}
</ul>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment