From 7fdc127e4f823508616676bf67265871b622d5e6 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Thu, 9 Jul 2015 19:00:34 +0530 Subject: add forgot password facility --- website/static/css/main.css | 12 ++- website/templates/cfp.html | 163 ++++++++++++++++++++++----------- website/templates/forgot-password.html | 52 +++++++++++ website/templates/update-password.html | 51 +++++++++++ website/templates/user-login.html | 61 ------------ website/templates/user-register.html | 12 +++ website/urls.py | 2 + website/views.py | 91 +++++++++++++++--- 8 files changed, 316 insertions(+), 128 deletions(-) create mode 100644 website/templates/forgot-password.html create mode 100644 website/templates/update-password.html delete mode 100644 website/templates/user-login.html (limited to 'website') diff --git a/website/static/css/main.css b/website/static/css/main.css index 7cb6991..c28a222 100644 --- a/website/static/css/main.css +++ b/website/static/css/main.css @@ -375,7 +375,6 @@ a:before, a:after { margin-right: 4px; } #footerwrap { - background: #2b2b2b; padding: 25px 0 15px 0; border-bottom: 1px solid #ddd; text-align: center; @@ -585,3 +584,14 @@ body .header { list-style-type: none; color: red; } + +.pwd-recovery-email { + height: 45px; + width: 350px; + margin-right: 5px; + border-radius: 4px; +} + +.pwd-recovery-btn { + height:45px; +} diff --git a/website/templates/cfp.html b/website/templates/cfp.html index 07d1041..8eab2c1 100644 --- a/website/templates/cfp.html +++ b/website/templates/cfp.html @@ -41,6 +41,15 @@
{% endif %} + {% if for_update_password %} +
+
+ × +

Kindly login to update your password

+
+
+
+ {% endif %} {% if login_required %}
@@ -50,62 +59,114 @@
{% endif %} + {% if password_updated %} +
+
+ × +

Password has been updated successfully !

+
+
+
+ {% endif %} + {% if password_reset %} +
+
+ × +

New login details have been sent to your email address. Kindly check your mail box. Do not forget to check your spam folder.

+
+
+
+ {% endif %}

Call for Proposals


-
-

We look forward to your proposals. Conference aims to promote Python for Scientific Computing and Education. Topics like pedagogy, exploration, modeling or from both applied and developmental perspectives are welcome. Contributions from academia as well as industry are welcome. If you wish to propose a talk at the conference, kindly follow the guidelines given below.

-
-

Proposal Guidelines

- -
-
-

Important Dates

- -
- {% if user and not user.is_anonymous %} - Submit a Talk - {% else %} -

Login/Register to submit a talk - {% if invalid %} -

-
- × -

Invalid Username/Password

-
-
-
- {% endif %} -
-
- {{ form.as_p }} - - Create an Account - {% csrf_token %} -
- -
-

OR

- Sign in with Google - Sign in with Github - Sign in with Facebook - {% endif %} +
+

We look forward to your proposals. Conference aims to promote Python for Scientific Computing and Education. Topics like pedagogy, exploration, modeling or from both applied and developmental perspectives are welcome. Contributions from academia as well as industry are welcome. If you wish to propose a talk at the conference, kindly follow the guidelines given below.

+
+

Proposal Guidelines

+
    +
  • Submit a proposal through this link +
  • The project you are willing to present should be an actual implementation rather than just an idea. +
  • Abstract should be of 300 to 700 words describing the topic, including its relevance to scientific computing. +
  • Proposals with an aim to promote a commercial product or service will be rejected. +
  • In your abstract mention about various tools/libraries used for development. +
  • Notification for selection/rejection of your proposal will be given through email. +
  • All selected proposals must be presented at the conference by at least one author. +
+
+
+

Important Dates

+
    +
  • CFP Open: July 5, 2015 +
  • CFP Close: October 15, 2015 +
  • Announcement of selected proposals: November 15, 2015 +
+
+ {% if user and not user.is_anonymous %} + Submit a Talk + {% else %} +

Login/Register to submit a talk + {% if invalid %} +

+
+ × +

Invalid Username/Password

+
+
+
+ {% endif %} + {% if for_update_password or password_reset %} +
+
+
+ × +

Login with the details sent to you to update your password.

+
+
+
+
+ {{ form.as_p }} + + Create an Account + Forgot Password ? + {% csrf_token %} +
+
+ {% elif password_updated %} +
+
+ {{ form.as_p }} + + Create an Account + Forgot Password ? + {% csrf_token %} +
+
+

OR

+ Sign in with Google + Sign in with Github + Sign in with Facebook +
+ {% else %} +
+
+ {{ form.as_p }} + + Create an Account + Forgot Password ? + {% csrf_token %} +
+
+

OR

+ Sign in with Google + Sign in with Github + Sign in with Facebook + {% endif %} +
+ {% endif %}
-
- +
{% endblock %} diff --git a/website/templates/forgot-password.html b/website/templates/forgot-password.html new file mode 100644 index 0000000..c96f491 --- /dev/null +++ b/website/templates/forgot-password.html @@ -0,0 +1,52 @@ +{% extends 'base.html' %} +{% load static %} + +{% block navbar %} + +{% endblock %} + +{% block content %} +
+
+
+

Password Recovery

+
+ {% if invalid_email %} +
+
+ × +

Invalid Email address

+
+
+
+ {% endif %} +
+

Enter the Email address you used while registration.

+

We will send you the updated login details on your Email address.

+
+ {% csrf_token %} +

+

+

+
+
+
+
+{% endblock %} diff --git a/website/templates/update-password.html b/website/templates/update-password.html new file mode 100644 index 0000000..dc02b23 --- /dev/null +++ b/website/templates/update-password.html @@ -0,0 +1,51 @@ +{% extends 'base.html' %} +{% load static %} + +{% block navbar %} + +{% endblock %} + +{% block content %} +
+
+
+

Update Password

+
+ {% if no_match %} +
+
+ × +

Password & Confirm Password did not match

+
+
+
+ {% endif %} +
+
+ {% csrf_token %} +

+

+

+

+
+
+
+
+{% endblock %} diff --git a/website/templates/user-login.html b/website/templates/user-login.html deleted file mode 100644 index 48b0e04..0000000 --- a/website/templates/user-login.html +++ /dev/null @@ -1,61 +0,0 @@ -{% extends 'base.html' %} -{% load static %} - -{% block navbar %} - -{% endblock %} - -{% block content %} -
-
-
-

Login

-
- {% if invalid %} -
-
- × -

Invalid Username/Password

-
-
-
- {% endif %} -
-
-
-

Login with your SciPy India Account -

- {{ form.as_p }} - - Create an Account - {% csrf_token %} -
-
-
-

OR

- Sign in with Google - Sign in with Github - Sign in with Facebook -
-
-
-
-
-{% endblock %} diff --git a/website/templates/user-register.html b/website/templates/user-register.html index 606c780..c09c08b 100644 --- a/website/templates/user-register.html +++ b/website/templates/user-register.html @@ -27,6 +27,18 @@

Sign Up

+ {% if email_registered %} +
+
+ × +

Email ID is already registered !

+
+

Have you already logged in using social logins ?

+

or

+

Click Here if you forgot your username or password

+
+
+ {% endif %}
diff --git a/website/urls.py b/website/urls.py index 324befe..0a4bc56 100644 --- a/website/urls.py +++ b/website/urls.py @@ -7,4 +7,6 @@ urlpatterns = patterns('', url(r'^submit-cfp/$', 'website.views.submitcfp', name='submitcfp'), url(r'^accounts/register/$', 'website.views.userregister', name='userregister'), url(r'^accounts/login/$', 'website.views.userlogin', name='userlogin'), + url(r'^accounts/forgot-password/$', 'website.views.forgotpassword', name='forgotpassword'), + url(r'^accounts/update-password/$', 'website.views.updatepassword', name='updatepassword'), ) diff --git a/website/views.py b/website/views.py index fdf019b..b32f99a 100644 --- a/website/views.py +++ b/website/views.py @@ -16,17 +16,30 @@ from django.core.mail import send_mail from website.forms import ProposalForm, UserRegisterForm, UserLoginForm from website.models import Proposal, Comments from social.apps.django_app.default.models import UserSocialAuth +import random +import string def userregister(request): context = {} context.update(csrf(request)) + registered_emails = [] + users = User.objects.all() + for user in users: + registered_emails.append(user.email) if request.user.is_anonymous(): if request.method == 'POST': form = UserRegisterForm(request.POST) if form.is_valid(): - form.save() - return HttpResponseRedirect('/2015/cfp') + data = form.cleaned_data + if data['email'] in registered_emails: + context['form'] = form + context['email_registered'] = True + return render_to_response('user-register.html', context) + else: + form.save() + context['registration_complete'] = True + return render_to_response('cfp.html', context) else: context.update(csrf(request)) context['form'] = form @@ -41,25 +54,70 @@ def userregister(request): return HttpResponseRedirect('/2015/cfp') -def userlogin(request): +def forgotpassword(request): context = {} + user_emails = [] context.update(csrf(request)) - if request.method == "POST": - username = request.POST['username'] - password = request.POST['password'] - user = authenticate(username=username, password=password) - if user is not None: - login(request, user) - context['user'] = user - return render_to_response('cfp.html', context) + if request.method == 'POST': + users = User.objects.all() + for user in users: + user_emails.append(user.email) + email = request.POST['email'] + if email == "": + context['invalid_email'] = True + return render_to_response("forgot-password.html", context) + if email in user_emails: + user = User.objects.get(email=email) + password = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8)) + user.set_password(password) + user.save() + sender_name = "SciPy India 2015" + sender_email = "scipy@fossee.in" + subject = "SciPy India - Password Reset" + to = (user.email, ) + message = """Dear """+user.first_name+""",\nYour password for SciPy India 2015 been reset. Your credentials are:\nUsername: """+user.username+"""\nPassword: """+password+"""\n\nWe recommend you to login with the given credentials & update your password immediately.\nLink to set new password: http://scipy.in/2015/update-password\n\nThank You !\n\nRegards,\n SciPy India,\nFOSSEE - IIT Bombay.""" + send_mail(subject, message, sender_email, to) + form = UserLoginForm() + context['form'] = form + context['password_reset'] = True + return render_to_response("cfp.html", context) else: - context['invalid'] = True - context['form'] = UserLoginForm - return render_to_response('user-login.html', context) + context['invalid_email'] = True + return render_to_response("forgot-password.html", context) + else: + return render_to_response('forgot-password.html', context) + + +def updatepassword(request): + context = {} + user = request.user + context.update(csrf(request)) + if user.is_authenticated(): + if request.method == 'POST': + new_password = request.POST['new_password'] + confirm = request.POST['confirm_new_password'] + if new_password == "" or confirm == "": + context['empty'] = True + return render_to_response("update-password.html", context) + if new_password == confirm: + user.set_password(new_password) + user.save() + context['password_updated'] = True + logout(request) + form = UserLoginForm() + context['form'] = form + return render_to_response("cfp.html", context) + else: + context['no_match'] = True + return render_to_response("update-password.html", context) + else: + return render_to_response("update-password.html", context) else: form = UserLoginForm() context['form'] = form - return render_to_response('user-login.html', context) + context['for_update_password'] = True + return render_to_response('cfp.html', context) + def home(request): @@ -88,6 +146,9 @@ def cfp(request): user = authenticate(username=username, password=password) if user is not None: login(request, user) + if 'next' in request.GET: + next = request.GET['next'] + return HttpResponseRedirect(next) context['user'] = user return render_to_response('cfp.html', context) else: -- cgit