Skip to content

Commit

Permalink
allauth login with github
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonimdo committed Aug 20, 2016
1 parent 93dffcb commit a217ea2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
24 changes: 21 additions & 3 deletions server/gistx/base_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
Expand All @@ -37,6 +36,15 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# `allauth` APPS
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.bitbucket',
'allauth.socialaccount.providers.github',
# our APPS
'management',
'login',
'gistsapi',
]
Expand All @@ -51,8 +59,6 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'gistx.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
Expand All @@ -69,6 +75,17 @@
},
]

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',
)
LOGIN_REDIRECT_URL = '/'

ROOT_URLCONF = 'gistx.urls'


WSGI_APPLICATION = 'gistx.wsgi.application'


Expand Down Expand Up @@ -115,6 +132,7 @@

USE_TZ = True

SITE_ID = 1

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
Expand Down
7 changes: 6 additions & 1 deletion server/gistx/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [

url(r'^admin/', admin.site.urls),
url(r'^accounts/', include('allauth.urls')),
url(r'^$', include('login.urls')),
]


24 changes: 24 additions & 0 deletions server/login/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""gistx URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from . import views

urlpatterns = [
url(r'^$', views.home, name="home"),
]


10 changes: 9 additions & 1 deletion server/login/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, JsonResponse
from django.shortcuts import render, render_to_response


# Create your views here.


@login_required(login_url='/')
def home(request):
return HttpResponse("Hello.")

0 comments on commit a217ea2

Please sign in to comment.