Skip to content

Commit

Permalink
Merge 9c80f61 into 687f983
Browse files Browse the repository at this point in the history
  • Loading branch information
CelineBoudier committed Apr 18, 2016
2 parents 687f983 + 9c80f61 commit 7223fee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions portal/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def logged_in_as_teacher(u):

return u.is_verified() or not using_two_factor(u)


def logged_in_as_student(u):
return hasattr(u, 'userprofile') and hasattr(u.userprofile, 'student')


def not_logged_in(u):
return not hasattr(u, 'userprofile')

def not_fully_logged_in(u):
return not_logged_in(u) or (not logged_in_as_student(u) and not logged_in_as_teacher(u))

def teacher_verified(view_func):
@wraps(view_func)
Expand Down
6 changes: 3 additions & 3 deletions portal/views/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from deploy.captcha import CAPTCHA_ENABLED

from portal.forms.registration import PasswordResetSetPasswordForm, StudentPasswordResetForm, TeacherPasswordResetForm
from portal.permissions import not_logged_in
from portal.permissions import not_logged_in, not_fully_logged_in
from portal.helpers.email import PASSWORD_RESET_EMAIL
from portal import app_settings
from ratelimit.decorators import ratelimit
Expand All @@ -64,7 +64,7 @@ def custom_2FA_login(request):
return LoginView.as_view()(request)


@user_passes_test(not_logged_in, login_url=reverse_lazy('current_user'))
@user_passes_test(not_fully_logged_in, login_url=reverse_lazy('current_user'))
def password_reset_check_and_confirm(request, uidb64=None, token=None, post_reset_redirect=None):
# Customised standard django auth view with customised form to incorporate checking the password set is strong enough
UserModel = get_user_model()
Expand All @@ -87,7 +87,7 @@ def student_password_reset(request, post_reset_redirect):
return password_reset(request, from_email=PASSWORD_RESET_EMAIL, template_name='registration/student_password_reset_form.html', password_reset_form=form, post_reset_redirect=post_reset_redirect, is_admin_site=True)


@user_passes_test(not_logged_in, login_url=reverse_lazy('current_user'))
@user_passes_test(not_fully_logged_in, login_url=reverse_lazy('current_user'))
def teacher_password_reset(request, post_reset_redirect):
form = TeacherPasswordResetForm if not CAPTCHA_ENABLED else decorate_with_captcha(TeacherPasswordResetForm, request,
recaptcha_client)
Expand Down

0 comments on commit 7223fee

Please sign in to comment.