-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Student Portal v1, working login and display session information
- Loading branch information
1 parent
d05a56e
commit e55296c
Showing
23 changed files
with
593 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,10 @@ | |
|
||
ALLOWED_HOSTS = [] | ||
|
||
EMAIL_HOST = "mail.iridiumtutoring.org" | ||
EMAIL_HOST_USER = "[email protected]" | ||
EMAIL_HOST_PASSWORD = "123456" | ||
EMAIL_PORT = 587 | ||
|
||
# Application definition | ||
|
||
|
@@ -102,7 +106,7 @@ | |
] | ||
|
||
# Auth backends | ||
AUTHENTICATION_BACKENDS = ['tutoring_student.backends.TutorBackend', 'django.contrib.auth.backends.ModelBackend'] | ||
AUTHENTICATION_BACKENDS = ['tutoring_student.backends.TutorBackend', 'tutoring_student.backends.StudentBackend', 'django.contrib.auth.backends.ModelBackend'] | ||
|
||
INTERNAL_IPS = [ | ||
# ... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
# backends.py | ||
from django.contrib.auth.backends import ModelBackend | ||
from .models import Tutor | ||
from .models import Tutor, Student | ||
|
||
|
||
# Custom authentication backend for Tutor model | ||
class TutorBackend(ModelBackend): | ||
def authenticate(self, request, username=None, password=None, **kwargs): | ||
def authenticate(self, request, email=None, password=None, **kwargs): | ||
try: | ||
tutor = Tutor.objects.get(user__email=username) | ||
tutor = Tutor.objects.get(email=email) | ||
except Tutor.DoesNotExist: | ||
return None | ||
|
||
# Check if the tutor exists and if the provided password is correct | ||
if tutor.user.check_password(password): | ||
return tutor.user | ||
return None | ||
|
||
|
||
# Custom authentication backend for Student model | ||
class StudentBackend(ModelBackend): | ||
def authenticate(self, request, fullName=None, email=None, password=None, **kwargs): | ||
try: | ||
student = Student.objects.get( | ||
studentName=fullName, email=email | ||
) | ||
if student is None: | ||
return None | ||
else: | ||
return student.user | ||
except Student.DoesNotExist: | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.