Skip to content

Commit 8914a0a

Browse files
Added django allauth registration model
1 parent dec4b4c commit 8914a0a

49 files changed

Lines changed: 1484 additions & 57 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

oshc/authentication/__init__.py

Whitespace-only changes.

oshc/authentication/admin.py

Whitespace-only changes.

oshc/authentication/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AuthenticationConfig(AppConfig):
5+
name = 'authentication'

oshc/authentication/migrations/__init__.py

Whitespace-only changes.

oshc/authentication/models.py

Whitespace-only changes.

oshc/authentication/regbackend.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from django.contrib.auth import get_user_model
2+
3+
4+
class EmailLoginBackend(object):
5+
'''
6+
This class checks that the user can be authenticated via our backend and if it fails than normal authentication backend is used.
7+
'''
8+
9+
def authenticate(self, username=None, password=None):
10+
user_cls = get_user_model()
11+
try:
12+
user = user_cls.objects.get(email=username)
13+
if user.check_password(password):
14+
return user
15+
except user_cls.DoesNotExist:
16+
return None
17+
return None
18+
19+
def get_user(self, user_id):
20+
user_cls = get_user_model()
21+
try:
22+
return user_cls.objects.get(pk=user_id)
23+
except user_cls.DoesNotExist:
24+
return None

oshc/authentication/tests.py

Whitespace-only changes.

oshc/authentication/urls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.conf.urls import url, include
2+
from . import views
3+
4+
urlpatterns = [
5+
url(r'^accounts/', include('allauth.urls')),
6+
url(r'^accounts/login/profile/', views.profile, name="profile")
7+
]

oshc/authentication/views.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.shortcuts import render
2+
3+
4+
def profile(request):
5+
return render(request, "profile.html")

0 commit comments

Comments
 (0)