diff --git a/oshc/main/regbackend.py b/oshc/main/regbackend.py deleted file mode 100644 index 31b2e6d..0000000 --- a/oshc/main/regbackend.py +++ /dev/null @@ -1,24 +0,0 @@ -from django.contrib.auth import get_user_model - - -class EmailLoginBackend(object): - ''' - This class checks that the user can be authenticated via our backend and if it fails than normal authentication backend is used. - ''' - - def authenticate(self, username=None, password=None): - user_cls = get_user_model() - try: - user = user_cls.objects.get(email=username) - if user.check_password(password): - return user - except user_cls.DoesNotExist: - return None - return None - - def get_user(self, user_id): - user_cls = get_user_model() - try: - return user_cls.objects.get(pk=user_id) - except user_cls.DoesNotExist: - return None diff --git a/oshc/main/templates/base.html b/oshc/main/templates/base.html index fca23a9..cd71109 100644 --- a/oshc/main/templates/base.html +++ b/oshc/main/templates/base.html @@ -35,13 +35,6 @@
  • Resources
  • Contact
  • Join Us!
  • - {% if user.is_authenticated %} -
  • Hey {{ user.username }}!
  • -
  • Logout
  • - {% else %} -
  • Sign In
  • -
  • Sign Up
  • - {% endif %} diff --git a/oshc/main/templates/registration/login.html b/oshc/main/templates/registration/login.html deleted file mode 100644 index 923be42..0000000 --- a/oshc/main/templates/registration/login.html +++ /dev/null @@ -1,35 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block content %} -
    -
    -
    -
    -

    {% trans 'Sign in to continue to OSHC' %}

    - - -
    -
    -
    -
    - -{% endblock %} diff --git a/oshc/main/templates/registration/logout.html b/oshc/main/templates/registration/logout.html deleted file mode 100644 index 0ffbd67..0000000 --- a/oshc/main/templates/registration/logout.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block content %} -
    -
    -

    {% trans "Logged out" %}

    -
    -
    -{% endblock %} diff --git a/oshc/main/templates/registration/password_reset_complete.html b/oshc/main/templates/registration/password_reset_complete.html deleted file mode 100644 index c388f87..0000000 --- a/oshc/main/templates/registration/password_reset_complete.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block content %} -
    -
    -

    {% trans "Password reset successfully" %}

    -

    {% trans "Log in" %}

    -
    -
    -{% endblock %} diff --git a/oshc/main/templates/registration/password_reset_confirm.html b/oshc/main/templates/registration/password_reset_confirm.html deleted file mode 100644 index 9188ab0..0000000 --- a/oshc/main/templates/registration/password_reset_confirm.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block content %} -
    -
    - {% if validlink %} -
    - {% csrf_token %} {{ form.as_p }} - -
    - {% else %} -

    {% trans "Password reset failed" %}

    - {% endif %} -
    -
    -{% endblock %} diff --git a/oshc/main/templates/registration/password_reset_done.html b/oshc/main/templates/registration/password_reset_done.html deleted file mode 100644 index a7a1a50..0000000 --- a/oshc/main/templates/registration/password_reset_done.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block content %} -
    -
    -

    {% trans "Email with password reset instructions has been sent." %}

    -
    -
    -{% endblock %} diff --git a/oshc/main/templates/registration/password_reset_email.html b/oshc/main/templates/registration/password_reset_email.html deleted file mode 100644 index 4628011..0000000 --- a/oshc/main/templates/registration/password_reset_email.html +++ /dev/null @@ -1,5 +0,0 @@ -{% load i18n %} -{% blocktrans %}Reset password at {{ site_name }}{% endblocktrans %}: -{% block reset_link %} - {{ protocol }}://{{ domain }}{% url 'auth_password_reset_confirm' uid token %} -{% endblock %} diff --git a/oshc/main/templates/registration/password_reset_form.html b/oshc/main/templates/registration/password_reset_form.html deleted file mode 100644 index 11bcda4..0000000 --- a/oshc/main/templates/registration/password_reset_form.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block content %} -
    -
    -
    -
    -

    {% trans 'Forgot Password' %}

    - -
    -
    -
    -
    -{% endblock %} diff --git a/oshc/main/templates/registration/registration_closed.html b/oshc/main/templates/registration/registration_closed.html deleted file mode 100644 index 2ef839c..0000000 --- a/oshc/main/templates/registration/registration_closed.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block content %} -
    -
    -

    {% trans "Registration is currently closed." %}

    -
    -
    -{% endblock %} diff --git a/oshc/main/templates/registration/registration_complete.html b/oshc/main/templates/registration/registration_complete.html deleted file mode 100644 index b102cf7..0000000 --- a/oshc/main/templates/registration/registration_complete.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block content %} -
    -
    -

    {% trans "You are now registered. Activation email sent." %}

    -
    -
    -{% endblock %} diff --git a/oshc/main/templates/registration/registration_form.html b/oshc/main/templates/registration/registration_form.html deleted file mode 100644 index d072436..0000000 --- a/oshc/main/templates/registration/registration_form.html +++ /dev/null @@ -1,45 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -x{% block content %} -
    -
    -
    -
    -

    {% trans 'Sign Up Here' %}

    - -
    -
    -
    -
    -{% endblock %} diff --git a/oshc/main/tests.py b/oshc/main/tests.py index 3a71d8b..63fc72e 100644 --- a/oshc/main/tests.py +++ b/oshc/main/tests.py @@ -5,54 +5,6 @@ from django.test import SimpleTestCase, TestCase from django.urls import reverse -from .regbackend import EmailLoginBackend - - -class EmailLoginBackendTests(TestCase): - - def setUp(self): - self.credentials = { - 'username': 'testuser', - 'email': 'testuser@email.com', - 'password': 'secret'} - self.user = User.objects.create_user(**self.credentials) - - def test_valid_username_login(self): - response = self.client.login(username=self.credentials['username'], - password=self.credentials['password']) - self.assertTrue(response) - - def test_invalid_username_login(self): - response = self.client.login(username='invalid_username', - password=self.credentials['password']) - self.assertFalse(response) - - def test_valid_email_login(self): - response = self.client.login(username=self.credentials['email'], - password=self.credentials['password']) - self.assertTrue(response) - - def test_invalid_email_login(self): - response = self.client.login(username='invalid_email', - password=self.credentials['password']) - self.assertFalse(response) - - def test_invalid_password_login(self): - response = self.client.login(username=self.credentials['email'], - password='incorrect_password') - self.assertFalse(response) - - def test_valid_get_user(self): - backend = EmailLoginBackend() - returned_user = backend.get_user(self.user.id) - self.assertEqual(returned_user.id, self.user.id) - - def test_invalid_get_user(self): - backend = EmailLoginBackend() - # The database has only one user. User with id=10 doesn't exists - returned_user = backend.get_user(user_id=10) - self.assertIsNone(returned_user) - class HomeViewTests(TestCase): @@ -60,14 +12,6 @@ def test_get_request(self): response = self.client.get(reverse("home")) self.assertEqual(response.status_code, 200) - def test_login_accessible(self): - response = self.client.get(reverse('auth_login')) - self.assertEqual(response.status_code, 200) - - def test_signup_accessible(self): - response = self.client.get(reverse('registration_register')) - self.assertEqual(response.status_code, 200) - class RequestSessionViewTests(SimpleTestCase): diff --git a/oshc/oshc/settings.py b/oshc/oshc/settings.py index 9450c01..6048878 100644 --- a/oshc/oshc/settings.py +++ b/oshc/oshc/settings.py @@ -10,7 +10,6 @@ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os -import dj_database_url BASE_DIR = os.path.dirname(os.path.dirname(__file__)) @@ -27,9 +26,9 @@ # Tuple of people who get error notifications ADMINS = [ - ('Tapasweni Pathak','tapaswenipathak@gmail.com'), - ('Nikhita Raghunath','nikitaraghunath@gmail.com'), - ('Ibrahim Jarif','jarifibrahim@gmail.com'), + ('Tapasweni Pathak', 'tapaswenipathak@gmail.com'), + ('Nikhita Raghunath', 'nikitaraghunath@gmail.com'), + ('Ibrahim Jarif', 'jarifibrahim@gmail.com'), ('Amar Prakash Pandey', 'amar.om1994@gmail.com') ] @@ -43,7 +42,6 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'registration', ) MIDDLEWARE_CLASSES = ( @@ -76,11 +74,6 @@ }, ] -AUTHENTICATION_BACKENDS = ( - 'main.regbackend.EmailLoginBackend', - 'django.contrib.auth.backends.ModelBackend' -) - # Database # https://docs.djangoproject.com/en/1.7/ref/settings/#databases @@ -91,25 +84,6 @@ } } -# Get DATABASE_URL environment variable and update default DATABASE settings -db_from_env = dj_database_url.config() -DATABASES['default'].update(db_from_env) - -# If True, users can register -REGISTRATION_OPEN = True -# One-week activation window; you may, of course, use a different value. -ACCOUNT_ACTIVATION_DAYS = 7 -# If True, the user will be automatically logged in. -REGISTRATION_AUTO_LOGIN = True -# If true, email will be sent as HTML -# REGISTRATION_EMAIL_HTML = True -# The page you want users to arrive at after they successfully log in -# The page users are directed to if they are not logged in, -LOGIN_REDIRECT_URL = 'home' -# and are trying to access pages requiring authentication -LOGIN_URL = '/accounts/login/' -LOGOUT_REDIRECT_URL = 'home' - # Internationalization # https://docs.djangoproject.com/en/1.7/topics/i18n/ diff --git a/oshc/oshc/urls.py b/oshc/oshc/urls.py index 3adcfe4..c72008a 100644 --- a/oshc/oshc/urls.py +++ b/oshc/oshc/urls.py @@ -4,5 +4,4 @@ urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'', include('main.urls')), - url(r'^accounts/', include('registration.backends.simple.urls')), ]