diff --git a/codeara/__pycache__/__init__.cpython-38.pyc b/codeara/__pycache__/__init__.cpython-38.pyc index a0b1dde..680306b 100644 Binary files a/codeara/__pycache__/__init__.cpython-38.pyc and b/codeara/__pycache__/__init__.cpython-38.pyc differ diff --git a/codeara/__pycache__/settings.cpython-38.pyc b/codeara/__pycache__/settings.cpython-38.pyc index 396fc72..23c2638 100644 Binary files a/codeara/__pycache__/settings.cpython-38.pyc and b/codeara/__pycache__/settings.cpython-38.pyc differ diff --git a/codeara/__pycache__/urls.cpython-38.pyc b/codeara/__pycache__/urls.cpython-38.pyc index dcfbfc3..3b2505e 100644 Binary files a/codeara/__pycache__/urls.cpython-38.pyc and b/codeara/__pycache__/urls.cpython-38.pyc differ diff --git a/codeara/__pycache__/wsgi.cpython-38.pyc b/codeara/__pycache__/wsgi.cpython-38.pyc index 147a142..2a25023 100644 Binary files a/codeara/__pycache__/wsgi.cpython-38.pyc and b/codeara/__pycache__/wsgi.cpython-38.pyc differ diff --git a/codeara/settings.py b/codeara/settings.py index 17be51f..5d4a72a 100644 --- a/codeara/settings.py +++ b/codeara/settings.py @@ -58,6 +58,8 @@ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + 'social_django.context_processors.backends', + 'social_django.context_processors.login_redirect', ], }, }, @@ -108,8 +110,11 @@ USE_TZ = True -ACCOUNT_EMAIL_REQUIRED = False -ACCOUNT_USERNAME_REQUIRED = False +Client_id = config('Client_id') +Client_secret = config('Client_secret') +ACCOUNT_EMAIL_REQUIRED = True +ACCOUNT_USERNAME_REQUIRED=False +ACCOUNT_AUTHENTICATION_METHOD="email" # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ @@ -121,9 +126,9 @@ 'django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend', ) - -Client_id = config('Client_id') -Client_secret = config('Client_secret') +EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend' +ACCOUNT_EMAIL_VERIFICATION='none' +EMAIL_FILE_PATH = os.path.join(BASE_DIR,'sent_emails') ERROR_MESSAGE = "Something went wrong please try again" CORECT_SUBMISSION_MESSAGE = "Correct!!" diff --git a/compiler/__pycache__/__init__.cpython-38.pyc b/compiler/__pycache__/__init__.cpython-38.pyc index 9d12ef7..6561e59 100644 Binary files a/compiler/__pycache__/__init__.cpython-38.pyc and b/compiler/__pycache__/__init__.cpython-38.pyc differ diff --git a/compiler/__pycache__/admin.cpython-38.pyc b/compiler/__pycache__/admin.cpython-38.pyc index 6229772..1e417a1 100644 Binary files a/compiler/__pycache__/admin.cpython-38.pyc and b/compiler/__pycache__/admin.cpython-38.pyc differ diff --git a/compiler/__pycache__/models.cpython-38.pyc b/compiler/__pycache__/models.cpython-38.pyc index 1821c46..35e9ef7 100644 Binary files a/compiler/__pycache__/models.cpython-38.pyc and b/compiler/__pycache__/models.cpython-38.pyc differ diff --git a/compiler/__pycache__/urls.cpython-38.pyc b/compiler/__pycache__/urls.cpython-38.pyc index 8175b14..1b252f4 100644 Binary files a/compiler/__pycache__/urls.cpython-38.pyc and b/compiler/__pycache__/urls.cpython-38.pyc differ diff --git a/compiler/__pycache__/views.cpython-38.pyc b/compiler/__pycache__/views.cpython-38.pyc index dc295b7..22189ce 100644 Binary files a/compiler/__pycache__/views.cpython-38.pyc and b/compiler/__pycache__/views.cpython-38.pyc differ diff --git a/compiler/migrations/__pycache__/0001_initial.cpython-38.pyc b/compiler/migrations/__pycache__/0001_initial.cpython-38.pyc index 1406713..2d20f0e 100644 Binary files a/compiler/migrations/__pycache__/0001_initial.cpython-38.pyc and b/compiler/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/compiler/migrations/__pycache__/__init__.cpython-38.pyc b/compiler/migrations/__pycache__/__init__.cpython-38.pyc index 6294822..cc506e7 100644 Binary files a/compiler/migrations/__pycache__/__init__.cpython-38.pyc and b/compiler/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/user/__pycache__/__init__.cpython-38.pyc b/user/__pycache__/__init__.cpython-38.pyc index a9ce016..c38e692 100644 Binary files a/user/__pycache__/__init__.cpython-38.pyc and b/user/__pycache__/__init__.cpython-38.pyc differ diff --git a/user/__pycache__/admin.cpython-38.pyc b/user/__pycache__/admin.cpython-38.pyc index 6d377c3..85238fe 100644 Binary files a/user/__pycache__/admin.cpython-38.pyc and b/user/__pycache__/admin.cpython-38.pyc differ diff --git a/user/__pycache__/models.cpython-38.pyc b/user/__pycache__/models.cpython-38.pyc index 73e6264..8367cf9 100644 Binary files a/user/__pycache__/models.cpython-38.pyc and b/user/__pycache__/models.cpython-38.pyc differ diff --git a/user/__pycache__/urls.cpython-38.pyc b/user/__pycache__/urls.cpython-38.pyc index 0394586..cd40694 100644 Binary files a/user/__pycache__/urls.cpython-38.pyc and b/user/__pycache__/urls.cpython-38.pyc differ diff --git a/user/__pycache__/views.cpython-38.pyc b/user/__pycache__/views.cpython-38.pyc index 20d8d6f..9f980bc 100644 Binary files a/user/__pycache__/views.cpython-38.pyc and b/user/__pycache__/views.cpython-38.pyc differ diff --git a/user/migrations/__pycache__/0001_initial.cpython-38.pyc b/user/migrations/__pycache__/0001_initial.cpython-38.pyc index 5e35ded..5099ae8 100644 Binary files a/user/migrations/__pycache__/0001_initial.cpython-38.pyc and b/user/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/user/migrations/__pycache__/0002_auto_20200118_2214.cpython-38.pyc b/user/migrations/__pycache__/0002_auto_20200118_2214.cpython-38.pyc index aaffa3d..c9d939c 100644 Binary files a/user/migrations/__pycache__/0002_auto_20200118_2214.cpython-38.pyc and b/user/migrations/__pycache__/0002_auto_20200118_2214.cpython-38.pyc differ diff --git a/user/migrations/__pycache__/__init__.cpython-38.pyc b/user/migrations/__pycache__/__init__.cpython-38.pyc index cfff6d9..9fb51af 100644 Binary files a/user/migrations/__pycache__/__init__.cpython-38.pyc and b/user/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/user/templates/account/login.html b/user/templates/account/login.html index 7be9392..bdca91b 100644 --- a/user/templates/account/login.html +++ b/user/templates/account/login.html @@ -6,26 +6,52 @@ {% block content %}

{% trans "Sign In" %}

+
+ {% csrf_token %} + + + {% for field in form %} +

+ {{ field.label_tag }} {{ field }} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} + {% for error in field.errors %} +

{{ error }}

+ {% endfor %} +

+ {% endfor %} +
Forgot Password? Reset Password +
+
+
{% csrf_token %}
+ Don't have an account? Create account +

{% endblock %} diff --git a/user/templates/account/password_change.html b/user/templates/account/password_change.html new file mode 100644 index 0000000..e8b0af7 --- /dev/null +++ b/user/templates/account/password_change.html @@ -0,0 +1,29 @@ +{% extends 'account/base.html' %} + +{% load i18n %} +{% load account socialaccount %} +{% block head_title %}{% trans "Password Management" %}{% endblock %} +{% block content %} +
+

{% trans "Password Management" %}

+
+ {% csrf_token %} + {% for field in form %} +

+ {{ field.label_tag }}
+ {{ field }} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} + {% for error in field.errors %} +

{{ error }}

+ {% endfor %} +

+ {% endfor %} +
+ + +
+
+
+{% endblock %} \ No newline at end of file diff --git a/user/templates/account/password_reset.html b/user/templates/account/password_reset.html new file mode 100644 index 0000000..1ec5342 --- /dev/null +++ b/user/templates/account/password_reset.html @@ -0,0 +1,32 @@ +{% extends 'account/base.html' %} + + +{% load i18n %} +{% load account socialaccount %} +{% block head_title %}{% trans "Password Management" %}{% endblock %} +{% block content %} +
+

{% trans "Password Management" %}

+
+ {% csrf_token %} +

Enter your e-mail address below, and we'll send you

+

an e-mail allowing you to reset it.

+ {% for field in form %} +

+ {{ field.label_tag }}
+ {{ field }} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} + {% for error in field.errors %} +

{{ error }}

+ {% endfor %} +

+ {% endfor %} +
+ + +
+
+
+{% endblock %} \ No newline at end of file diff --git a/user/templates/account/password_reset_done.html b/user/templates/account/password_reset_done.html new file mode 100644 index 0000000..88fd2b0 --- /dev/null +++ b/user/templates/account/password_reset_done.html @@ -0,0 +1,23 @@ +{% extends 'account/base.html' %} + + +{% load i18n %} +{% load account socialaccount %} +{% block head_title %}{% trans "Password Management" %}{% endblock %} +{% block content %} +
+

{% trans "Password Management" %}

+
+ {% csrf_token %} +

We have sent you an e-mail. Please contact us if you do not receive it within a few minutes.

+ {% for field in form %} +

+ {% for error in field.errors %} +

{{ error }}

+ {% endfor %} +

+ {% endfor %} +
+
+
+{% endblock %} \ No newline at end of file diff --git a/user/templates/account/password_reset_from_key.html b/user/templates/account/password_reset_from_key.html new file mode 100644 index 0000000..06b2272 --- /dev/null +++ b/user/templates/account/password_reset_from_key.html @@ -0,0 +1,38 @@ +{% extends "account/base.html" %} + +{% load i18n %} + +{% block content %} +

{% if token_fail %}{% trans "Bad Token" %}{% endif %}

+ + {% if token_fail %} + {% url 'account_reset_password' as passwd_reset_url %} +

{% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a new password reset.{% endblocktrans %}

+ {% else %} + {% if form %} +
+

{% trans "Password Management" %}

+
+ {% csrf_token %} + {% for field in form %} +

+ {{ field.label_tag }}
+ {{ field }} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} + {% for error in field.errors %} +

{{ error }}

+ {% endfor %} +

+ {% endfor %} +
+ +

+
+
+ {% else %} +

{% trans 'Your password is now changed.' %}

+ {% endif %} + {% endif %} +{% endblock %} \ No newline at end of file diff --git a/user/templates/account/password_reset_from_key_done.html b/user/templates/account/password_reset_from_key_done.html new file mode 100644 index 0000000..843886f --- /dev/null +++ b/user/templates/account/password_reset_from_key_done.html @@ -0,0 +1,23 @@ +{% extends 'account/base.html' %} + + +{% load i18n %} +{% load account socialaccount %} +{% block head_title %}{% trans "Password Management" %}{% endblock %} +{% block content %} +
+

{% trans "Password Management" %}

+
+ {% csrf_token %} +

Your Password is now changed

+ {% for field in form %} +

+ {% for error in field.errors %} +

{{ error }}

+ {% endfor %} +

+ {% endfor %} +
+
+
+{% endblock %} \ No newline at end of file diff --git a/user/templates/account/password_set.html b/user/templates/account/password_set.html new file mode 100644 index 0000000..a688603 --- /dev/null +++ b/user/templates/account/password_set.html @@ -0,0 +1,30 @@ +{% extends 'account/base.html' %} + + +{% load i18n %} +{% load account socialaccount %} +{% block head_title %}{% trans "Password Management" %}{% endblock %} +{% block content %} +
+

{% trans "Password Management" %}

+
+ {% csrf_token %} + {% for field in form %} +

+ {{ field.label_tag }}
+ {{ field }} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} + {% for error in field.errors %} +

{{ error }}

+ {% endfor %} +

+ {% endfor %} +
+ + +
+
+
+{% endblock %} \ No newline at end of file diff --git a/user/templates/account/signup.html b/user/templates/account/signup.html new file mode 100644 index 0000000..97abc8f --- /dev/null +++ b/user/templates/account/signup.html @@ -0,0 +1,30 @@ +{% extends 'account/base.html' %} + + +{% load i18n %} +{% load account socialaccount %} +{% block head_title %}{% trans "Sign Up" %}{% endblock %} +{% block content %} +
+

{% trans "Sign Up" %}

+
+ {% csrf_token %} + {% for field in form %} +

+ {{ field.label_tag }}
+ {{ field }} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} + {% for error in field.errors %} +

{{ error }}

+ {% endfor %} +

+ {% endfor %} +
+ + +
+
+
+{% endblock %} \ No newline at end of file diff --git a/user/templates/profile.html b/user/templates/profile.html index 1c79523..0f03470 100644 --- a/user/templates/profile.html +++ b/user/templates/profile.html @@ -1,16 +1,26 @@ {% extends 'base.html' %} - +{% load static%} {% block body %} {% block content %} {% load account socialaccount %}

WELCOME,

+ {% if user.socialaccount_set.all.0.get_avatar_url%}

+ {% else %} +

+ {% endif %} {{ user.socialaccount_set.all.0.extra_data.name }} ({{ user }}).

No. of Submissions : {{usr.n_subm}}
-
Languages Used : {{usr.lang}}
+
Languages Used : {{usr.lang}}

+ {% if user.has_usable_password %} + Password Management + {% else %} + Password Management + {% endif %} +

{% endblock content %} diff --git a/user/templates/socialaccount/signup.html b/user/templates/socialaccount/signup.html new file mode 100644 index 0000000..8a05414 --- /dev/null +++ b/user/templates/socialaccount/signup.html @@ -0,0 +1,30 @@ +{% extends 'account/base.html' %} + + +{% load i18n %} +{% load account socialaccount %} +{% block head_title %}{% trans "Sign Up" %}{% endblock %} +{% block content %} +
+

{% trans "Sign Up" %}

+
+ {% csrf_token %} + {% for field in form %} +

+ {{ field.label_tag }}
+ {{ field }} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} + {% for error in field.errors %} +

{{ error }}

+ {% endfor %} +

+ {% endfor %} +
+ + +
+
+
+{% endblock %} \ No newline at end of file diff --git a/user/views.py b/user/views.py index f6312f6..87bb737 100644 --- a/user/views.py +++ b/user/views.py @@ -3,13 +3,16 @@ from django.core.exceptions import ObjectDoesNotExist from google.auth.transport import requests from django.contrib.auth.models import User +from django.contrib.auth.forms import AdminPasswordChangeForm, PasswordChangeForm +from django.contrib.auth import update_session_auth_hash +from django.contrib import messages from django.http import HttpResponse, JsonResponse import os from compiler.models import Question from user.models import User_profile from decouple import config from allauth.socialaccount.models import SocialAccount - +from django.contrib.auth.decorators import login_required def home(request): ques = Question.objects.order_by('?').first() @@ -42,4 +45,24 @@ def leaderboard(request): users = {"user":p} return render(request,"leaderboard.html",users) +'''@login_required +def password(request): + if request.user.has_usable_password(): + PasswordForm = PasswordChangeForm + else: + PasswordForm = AdminPasswordChangeForm + + if request.method == 'POST': + form = PasswordForm(request.user, request.POST) + if form.is_valid(): + form.save() + update_session_auth_hash(request, form.user) + messages.success(request, 'Your password was successfully updated!') + return redirect('password') + else: + messages.error(request, 'Please correct the error below.') + else: + form = PasswordForm(request.user) + return render(request, 'password.html', {'form': form}) ''' +