Skip to content

Commit f01f550

Browse files
Merge branch 'vaibhavsingh97-Patch1/registrationModel' into predev
2 parents 184bed4 + e3448ea commit f01f550

Some content is hidden

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

52 files changed

+1616
-58
lines changed

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
url(r'^ajax/validate_username/$', views.validate_username, name='validate_username'),
8+
]

oshc/authentication/views.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from django.shortcuts import render
2+
from django.contrib.auth.models import User
3+
from django.http import JsonResponse
4+
5+
6+
def profile(request):
7+
return render(request, "profile.html")
8+
9+
10+
def validate_username(request):
11+
username = request.GET.get('username', None)
12+
data = {
13+
'is_present': User.objects.filter(username__iexact=username).exists()
14+
}
15+
return JsonResponse(data)

oshc/main/static/main/css/app.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,11 @@ footer .container {
354354
border-top-right-radius: 0;
355355
}
356356

357-
.forgot-password {
357+
.form-registration .forgot-password {
358358
margin-top: 10px;
359359
}
360360

361-
.new-account {
361+
.form-registration .new-account {
362362
display: block;
363363
margin-top: 10px;
364364
}

0 commit comments

Comments
 (0)