def reset(request):
    context={}
    if request.method == 'POST':
        form = request.POST
        data = {
            'form': form,
        }
        value = data['form']
        user_input=value.get("email",0)
        try:
            user = User.objects.get(email = user_input)
        except User.DoesNotExist:
            user = None
        if Learner.objects.filter(user__exact = user) or Teacher.objects.filter(user__exact = user):
            return password_reset(request, template_name='account/reset.html',
            email_template_name='account/reset_email.html',
            subject_template_name='account/reset_subject.txt',
            post_reset_redirect=reverse('login'))
        else:
            context['error'] = "This email address is invalid"
            context['form']=PasswordResetForm()
            return render(request, 'account/reset.html',context)
    return password_reset(request, template_name='account/reset.html',
            email_template_name='account/reset_email.html',
            subject_template_name='account/reset_subject.txt',
            post_reset_redirect=reverse('reset'))
Exemplo n.º 2
0
	def post(self,request):
		try:
			email = request.DATA['email']
			password_reset(request,email_template_name='account/reset_email.html',html_email_template_name='account/reset_email.html',subject_template_name='account/reset_subject.txt')
			return Response({'reset':True})
		except Exception as e:
			print e
			return Response({'reset':False})
Exemplo n.º 3
0
 def post(self, request, *args, **kwargs):
     email = request.POST['email']
     target_user = User.objects.get(email=email)
     if not target_user.is_staff:
         kwargs.update(post_reset_redirect='/to_email_confirm')
         kwargs.update(template_name='customer/website/customer.reset.password.form.html')
         kwargs.update(email_template_name='customer/website/customer.reset.password.email.html')
         kwargs.update(subject_template_name='customer/website/customer.reset.password.subject.txt')
     password_reset(request=request, **kwargs)
     return HttpResponseJson(exceptions.build_success_response_result(), request)
Exemplo n.º 4
0
def my_password_reset(request):
    
    if request.method == 'GET':
        return password_reset(request)

    else:
        email = request.POST['email']
        users = User.objects.filter(email = email)
        if len(users) == 1 and users[0].password == '!':
             return HttpResponseRedirect(settings.OFREG_URL+settings.OFREG_RESET_PATH)
        else:
            return password_reset(request, password_reset_form=LDAPPasswordResetForm)
Exemplo n.º 5
0
def reset_password(request):
    context = {}
    email = ''
    if request.method == "POST":
        if request.POST.get('email'):
            email = request.POST.get('email')
            print "$$$", len(email)
            if len(email) > 20:
                error = """
                Email too long
                (For some reason, it will make the server crash, so we forbid it now.
                Sorry for the inconvenience!)
                """
                context['error'] = error
                return render(request, 'accounts/password_reset_form_fail.html', context)

            users = User.objects.filter(email=email)
            for user in users:
                token = default_token_generator.make_token(user)
                reset_message = """
                    You just request to reset your password by your email.\n
                    Please click the link below to verify your email address:\n
                    http://%s%s
                    [This is the part remaining to be implemented!]
                    \n
                    If this is not your operation, just ignore this email.
                """ % (request.get_host(), reverse('confirm', args=(user.username, token, )))


                send_mail(subject = "Reset password in Grumblr.",
                          message = reset_message,
                          from_email="*****@*****.**",
                          recipient_list = [email])
        if users:
            return password_reset(request,
                template_name='accounts/password_reset_form.html',
                email_template_name='accounts/password_reset_email.html',
                password_reset_form=PasswordResetForm,
                token_generator=default_token_generator,
                post_reset_redirect=reverse('reset_done'))
        else:
            error = "Email doesn't exist!"
            context['error'] = error
            return render(request, 'accounts/password_reset_form_fail.html', context)


    return password_reset(request,
        template_name='accounts/password_reset_form.html',
        email_template_name='accounts/password_reset_email.html',
        password_reset_form=PasswordResetForm,
        token_generator=default_token_generator,
        post_reset_redirect=reverse('reset_done'))
Exemplo n.º 6
0
def password_reset(request):
    if not request.is_ajax() or not request.method == 'POST':
        raise Http404()
    
    email = request.POST.get('email')
    try:
        validate_email(email)
        auth_views.password_reset(request)
    except ValidationError:
        pass

    return HttpResponse(json.dumps({}),
        content_type="application/json")
Exemplo n.º 7
0
def reset(request):
    template_name='custom/custom_password_reset_form.html'
    if request.POST:
        email = request.POST.get('email', None)
        if email is not None:
            exist = User.objects.filter(email__iexact=email)
            template_name='custom/custom_password_reset_form.html'
            if exist:
                return password_reset(request, template_name=template_name,
                          email_template_name='custom/reset_email.html')
            else:
                return render(request, template_name=template_name, context={'email':False})
    else:
        return password_reset(request, template_name=template_name,
                          email_template_name='custom/reset_email.html', extra_context={'email':True})
def password_reset(request):
  return djauth_views.password_reset(request,
    template_name='tracker/password_reset.html',
    email_template_name='password_reset_template',
    password_reset_form=forms.PostOfficePasswordResetForm,
    from_email=viewutil.get_default_email_from_user(),
    extra_context={'event': viewutil.get_event(None), 'csrftoken': get_csrf_token(request)})
Exemplo n.º 9
0
def custom_password_reset(request,
                          template_name='registration/password_reset_form.html',
                          email_template_name='registration/password_reset_email.html',
                          subject_template_name='registration/password_reset_subject.txt',
                          password_reset_form=PasswordResetForm,
                          token_generator=default_token_generator,
                          post_reset_redirect=None,
                          from_email=settings.EMAIL_FROM,
                          current_app=None,
                          extra_context=None,
                          html_email_template_name=None):
    response = password_reset(request,
                              template_name=template_name,
                              email_template_name=email_template_name,
                              subject_template_name=subject_template_name,
                              password_reset_form=password_reset_form,
                              token_generator=token_generator,
                              post_reset_redirect=post_reset_redirect,
                              from_email=from_email,
                              current_app=current_app,
                              extra_context=extra_context,
                              html_email_template_name=html_email_template_name)
    if request.method == 'POST' and isinstance(response, HttpResponseRedirect):
        request.session['anonym_user_email'] = request.POST.get('email')
    return response
Exemplo n.º 10
0
def reset_password(request):
    """A wrapper function for password reset"""
    return password_reset(request,
        template_name='generator/password_reset.html',
        email_template_name='generator/password_reset_email.html',
        subject_template_name='generator/password_reset_email_subject.txt',
        post_reset_redirect=reverse('password_reset_done'))
Exemplo n.º 11
0
def password_reset_initial(request):
    return auth_views.password_reset(
        request,
        template_name="base/auth/forgot_password_initial.html",
        email_template_name="base/auth/forgot_password_email.html",
        from_email="*****@*****.**"
    )
Exemplo n.º 12
0
def reset(request):
	'''
	This method is used to reset the password from the login screen. It use's Django's
	password_reset functionality.
	'''

	return password_reset(request, post_reset_redirect=reverse('index'))
Exemplo n.º 13
0
def password_reset(request):
    return aviews.password_reset(request, is_admin_site=False,
        template_name='password_reset_form.html',
        email_template_name='password_reset_email.html',
        subject_template_name='password_reset_subject.txt',
        password_reset_form=forms.PasswordResetForm,
        post_reset_redirect=reverse('account:password_reset_done'))
Exemplo n.º 14
0
def reset(request):
    return password_reset(
        request,
        template_name='account/reset-password.html',
        email_template_name='account/reset-password-email.html',
        subject_template_name='account/reset-password-subject.txt',
        post_reset_redirect=reverse('password_reset_done'))
Exemplo n.º 15
0
 def delegate_password_reset_render(request, template, context=None, status=200):
     return djauth_views.password_reset(request,
                                        template_name=template,
                                        email_template_name=tracker.auth.default_password_reset_template(),
                                        password_reset_form=forms.PostOfficePasswordResetForm,
                                        from_email=viewutil.get_default_email_from_user(),
                                        extra_context=context)
Exemplo n.º 16
0
def reset_pw_view(request):
    """ View to send an e-mail to reset password. """
    return password_reset(request,
        template_name="reset.html",
        email_template_name="reset_email.html",
        subject_template_name="reset_subject.txt",
        post_reset_redirect=reverse('login'))
Exemplo n.º 17
0
def password_reset(request):
  return auth_views.password_reset(request, 
    template_name='tracker/password_reset.html', 
    email_template_name='password_reset_template',
    password_reset_form=PostOfficePasswordResetForm,
    from_email=settings.EMAIL_FROM_USER, 
    extra_context={'event': viewutil.get_event(None), 'csrftoken': get_csrf_token(request)})
Exemplo n.º 18
0
def reset(request):
    return password_reset(request,
                          template_name='tethys_portal/accounts/password_reset/reset_request.html',
                          email_template_name='tethys_portal/accounts/password_reset/reset_email.html',
                          subject_template_name='tethys_portal/accounts/password_reset/reset_subject.txt',
                          post_reset_redirect=reverse('accounts:login')
    )
Exemplo n.º 19
0
 def post(self, request, *args, **kwargs):
     form = self.form_class(request.POST)
     if form.is_valid():
         return password_reset(request=self.request, **self.kwargs)
     else:
         context = {'form': form}
         return self.render_to_response(context=context)
Exemplo n.º 20
0
	def dispatch(self,request,*args,**kwargs):
		return password_reset(
			request,
			template_name = 'inicio/recuperar_login_form.html',
			email_template_name = 'inicio/recuperar_login_email.html',
			subject_template_name = 'inicio/recuperar_login_email_asunto.txt',
			post_reset_redirect = reverse('inicio:recuperar_login_email_enviado'))
Exemplo n.º 21
0
def reset(request):
    return password_reset(
        request,
        template_name='password_reset_form.html',
        email_template_name='password_reset_email.html',
        subject_template_name='password_reset_subject.txt',
        post_reset_redirect=reverse('auth_login')
    )
Exemplo n.º 22
0
def reset(request):  # Sends the template
    return password_reset(
        request,
        template_name="portal/reset.html",
        email_template_name="portal/reset_email.html",
        subject_template_name="portal/reset_subject.txt",
        post_reset_redirect=reverse("portal:login"),
    )
Exemplo n.º 23
0
def exception_safe_password_reset(request, *args, **kwargs):
    try:
        return password_reset(request, *args, **kwargs)
    except None: 
        vals = {'error_msg':'There was a problem with your request',
                'error_details':sys.exc_info(),
                'show_homepage_link': 1 }
        return render_to_response('error.html', vals, context_instance=RequestContext(request))
Exemplo n.º 24
0
def reset(request):
	# Wrap the built-in password reset view and pass it the arguments
	# like the template name, email template name, subject template name
	# and the url to redirect after the password reset is initiated.
	return password_reset(request, template_name='registration/reset.html',
		email_template_name='registration/reset_email.html',
		subject_template_name='registration/reset_subject.txt',
		post_reset_redirect=reverse('success'))
Exemplo n.º 25
0
def password_reset(request):
    return auth_views.password_reset(
        request,
        post_reset_redirect=PASSWORD_RESET_REDIRECT_URL,
        extra_context=EXTRA_CONTEXT,
        password_reset_form=PasswordResetForm,
        template_name=get_full_template_name('password_reset_form.html')
    )
Exemplo n.º 26
0
def custom_password_reset(request, **kwargs):
    if request.user.is_authenticated() and not request.user.email:
        messages.error(request, _("You do not have a valid email set. Please verify your email first."))
        return redirect('spirit:user:update')
    if request.method == "POST" and request.is_limited:
        return redirect(reverse("spirit:user:auth:password-reset"))

    return password_reset(request, **kwargs)
Exemplo n.º 27
0
def reset(request):
    return password_reset(
        request,
        template_name="account/reset-password.html",
        email_template_name="account/reset-password-email.html",
        subject_template_name="account/reset-password-subject.txt",
        post_reset_redirect=reverse("signin"),
    )
Exemplo n.º 28
0
def password_reset(request, **kwargs):
    """Custom view to override form."""
    kwargs.update({
        "from_email": (
            request.localconfig.parameters.get_value("sender_address")),
        "password_reset_form": forms.PasswordResetForm
    })
    return auth_views.password_reset(request, **kwargs)
Exemplo n.º 29
0
def password_reset(request):
    response = views.password_reset(
        request,
        template_name='registration/password_reset.html',
        email_template_name='registration/password_reset_email.html',
        post_reset_redirect=reverse('pong_app.views.registration.password_reset_done')
    )
    return response
Exemplo n.º 30
0
def reset_password(request):
    template_name = 'registration/reset_my_password.html'
    email_template_name = 'registration/reset_my_password_email.html'
    subject_template_name = 'registration/reset_my_password_subject.txt'
    post_reset_redirect = reverse('account_reset_password_done')
    return password_reset(request, is_admin_site=False, template_name=template_name,
                            email_template_name=email_template_name, subject_template_name=subject_template_name,
                            post_reset_redirect=post_reset_redirect, password_reset_form=CustomPasswordResetForm)
Exemplo n.º 31
0
def reset(request):
    # Wrap the built-in password reset view and pass it the arguments
    # like the template name, email template name, subject template name
    # and the url to redirect after the password reset is initiated.
    if request.user.is_authenticated():
        return HttpResponseRedirect('/metrics/')
    else:
        return password_reset(request,
                              template_name='reset.html',
                              email_template_name='reset_email.html',
                              subject_template_name='reset_subject.txt',
                              post_reset_redirect=reverse('resetsent'))
Exemplo n.º 32
0
 def post(self, request):
     email = request.POST['email']
     # NOTE this does not provide the email address yet, since it seems like there
     #      is a bug in django (at least imo). The path with HttpResponseRedirect omits the extra_context-field
     # s.a. http://python.6.x6.nabble.com/Django-24944-Have-password-reset-pass-extra-
     #        context-to-the-email-template-rendering-as-well-td5097076.html
     # TODO did I mean url instead of email address?
     return password_reset(
         request,
         template_name='registration/password_reset_form.html',
         post_reset_redirect='password_reset_done',
         extra_context={'email': email})
Exemplo n.º 33
0
def recover(request):
    """
    Reset password based on email address or username.

    Send email to user.
    """
    return password_reset(request,
                          template_name="accounts/recover.html",
                          email_template_name="accounts/reset_email.html",
                          subject_template_name="accounts/reset_subject.txt",
                          password_reset_form=UserPasswordResetForm,
                          post_reset_redirect=reverse(recover_requested))
Exemplo n.º 34
0
 def delegate_password_reset_render(request,
                                    template,
                                    context=None,
                                    status=200):
     return djauth_views.password_reset(
         request,
         template_name=template,
         email_template_name=tracker.auth.default_password_reset_template(),
         password_reset_form=forms.PostOfficePasswordResetForm,
         from_email=viewutil.get_default_email_from_user(),
         post_reset_redirect=reverse('tracker:password_reset_done'),
         extra_context=context)
Exemplo n.º 35
0
def password_reset(request):
    context = {}
    context["page_title"] = _("Password reset")

    return django_auth_views.password_reset(
        request,
        template_name='account/password-reset.html',
        extra_context=context,
        password_reset_form=account_forms.CustomPasswordResetForm,
        subject_template_name='account/email/password_reset_subject.txt',
        email_template_name='account/email/password-reset-email.html',
        post_reset_redirect=reverse('account:password-reset-done'))
Exemplo n.º 36
0
def exception_safe_password_reset(request, *args, **kwargs):
    try:
        return password_reset(request, *args, **kwargs)
    except None:
        vals = {
            'error_msg': 'There was a problem with your request',
            'error_details': sys.exc_info(),
            'show_homepage_link': 1
        }
        return render_to_response('error.html',
                                  vals,
                                  context_instance=RequestContext(request))
Exemplo n.º 37
0
 def post_list(self, request, **kwargs):
     deserialized = self.deserialize(
         request, request.raw_post_data,
         format=request.META.get('CONTENT_TYPE', 'application/json')
     )
     bundle = self.build_bundle(data=dict_strip_unicode_keys(deserialized))
     self.is_valid(bundle, request)
     post = request.POST.copy()
     post.update(bundle.data)
     request.POST = post
     request._dont_enforce_csrf_checks = True
     response = password_reset(request)
     return HttpCreated(location=response['location'])
Exemplo n.º 38
0
def password_reset(request, domain):
    kwargs = copy.deepcopy(PASSWORD_RESET_KWARGS)
    kwargs[
        'template_name'] = 'icds_reports/mobile/mobile_password_reset_form.html'
    # submit the form back to this view instead of the default
    kwargs['extra_context']['form_submit_url'] = reverse(
        'cas_mobile_dashboard_password_reset', args=[domain])
    kwargs['extra_context']['login_url'] = reverse(
        'cas_mobile_dashboard_login', args=[domain])
    # so that we can redirect to a custom "done" page
    kwargs['post_reset_redirect'] = reverse(
        'cas_mobile_dashboard_password_reset_done', args=[domain])
    return auth_views.password_reset(request, **kwargs)
Exemplo n.º 39
0
Arquivo: views.py Projeto: jicksy/SDS
def password_reset(request):
    response = views.password_reset(
        request=request,
        template_name='password_reset/password_reset_form.html',
        email_template_name='password_reset/password_reset_email.html',
        subject_template_name='password_reset/password_reset_subject.txt',
        password_reset_form=PasswordResetForm,
        token_generator=default_token_generator,
        post_reset_redirect=reverse("PasswordReset:password_reset_done"),
        from_email=None,
        current_app=None,
        extra_context=None)
    return response
Exemplo n.º 40
0
def custom_password_reset(request):
    response = password_reset(
        request,
        template_name='registration/recover.html',
        email_template_name='registration/reset_email.html',
        post_reset_redirect='home')

    if not isinstance(response, TemplateResponse):
        messages.success(
            request,
            _("We have sent you the email with reset password instructions"))

    return response
Exemplo n.º 41
0
def password_reset(request):
    """ view that handles the recover password process """

    template_name = "accounts/password_reset_form.jade"
    email_template_name = "emails/password_reset.html"

    success_url = "/accounts/password_email_sent"

    res = auth_views.password_reset(request,
                                    post_reset_redirect=success_url,
                                    template_name=template_name,
                                    email_template_name=email_template_name)
    return res
Exemplo n.º 42
0
def password_reset(request):
    kwargs = {
        'template_name': 'password_reset/form.html',
        'email_template_name': 'password_reset/email.html',
        'subject_template_name': 'password_reset/subject.html',
        'post_reset_redirect': reverse_lazy('homepage')
    }

    if request.method == 'POST' and request.POST.get('email'):
        messages.add_message(request, messages.SUCCESS, _('Email instructions have been sent.'),
                             fail_silently=True)
    response = auth_views.password_reset(request, **kwargs)

    return response
Exemplo n.º 43
0
def password_reset(request):
    response = auth_views.password_reset(
        request,
        template_name="account/password_reset_form.html",
        email_template_name="account/password_reset_email.txt",
        password_reset_form=forms.PasswordResetForm,
        post_reset_redirect=DEFAULT_REDIRECT)

    if response.status_code == 302:
        messages.success(
            request, "Your password reset request has been received. "
            "Check your email for further instructions.")

    return response
Exemplo n.º 44
0
def my_password_reset(request):

    if request.method == 'POST':
        form = PasswordResetForm(request.POST)
        if form.is_valid():
            if MyUser.objects.filter(
                    email=form.cleaned_data['email']).count() == 0:
                return render(request,
                              'registration/password_reset_email_error.html')

    return password_reset(
        request,
        template_name='registration/password_reset_form.html',
        post_reset_redirect='/user/password/reset/done/')
Exemplo n.º 45
0
def password_reset2(request):
    """django.contrib.auth.views.password_reset view (forgotten password)"""
    saveViewsLog(request, "apps.account.views.password_reset2")
    if not request.user.is_authenticated():
        try:
            return password_reset(
                request,
                template_name='account/password_reset_form.html',
                email_template_name='account/password_reset_email.html',
                subject_template_name='account/password_reset_subject.txt',
                post_reset_redirect='/account/password/reset/done/')
        except Exception:
            return HttpResponseRedirect("/account/password/reset/done/")
    else:
        return HttpResponseRedirect("/account/")
Exemplo n.º 46
0
def custom_password_reset(request):
    template = 'registration/%s/password_reset_form.html' % settings.PROJECT
    email_domain = 'my.jobs'
    if getattr(settings, 'SITE', None):
        email_domain = settings.SITE.email_domain

    from_email = settings.EMAIL_FORMATS[settings.FORGOTTEN_PASSWORD]['address']
    from_email = from_email.format(domain=email_domain.lower())

    response = password_reset(request,
                              password_reset_form=CustomPasswordResetForm,
                              from_email=from_email,
                              template_name=template)
    response.delete_cookie('loggedout')
    return response
Exemplo n.º 47
0
    def test_titles(self):
        rf = RequestFactory()
        user = User.objects.create_user('jsmith', '*****@*****.**', 'pass')
        user = authenticate(username=user.username, password='******')
        request = rf.get('/somepath/')
        request.user = user

        response = password_reset(request, post_reset_redirect='dummy/')
        self.assertContains(response, '<title>Password reset</title>')
        self.assertContains(response, '<h1>Password reset</h1>')

        response = password_reset_done(request)
        self.assertContains(response,
                            '<title>Password reset successful</title>')
        self.assertContains(response, '<h1>Password reset successful</h1>')

        # password_reset_confirm invalid token
        response = password_reset_confirm(request,
                                          uidb64='Bad',
                                          token='Bad',
                                          post_reset_redirect='dummy/')
        self.assertContains(response,
                            '<title>Password reset unsuccessful</title>')
        self.assertContains(response, '<h1>Password reset unsuccessful</h1>')

        # password_reset_confirm valid token
        default_token_generator = PasswordResetTokenGenerator()
        token = default_token_generator.make_token(user)
        uidb64 = force_text(urlsafe_base64_encode(force_bytes(user.pk)))
        response = password_reset_confirm(request,
                                          uidb64,
                                          token,
                                          post_reset_redirect='dummy/')
        self.assertContains(response, '<title>Enter new password</title>')
        self.assertContains(response, '<h1>Enter new password</h1>')

        response = password_reset_complete(request)
        self.assertContains(response, '<title>Password reset complete</title>')
        self.assertContains(response, '<h1>Password reset complete</h1>')

        response = password_change(request, post_change_redirect='dummy/')
        self.assertContains(response, '<title>Password change</title>')
        self.assertContains(response, '<h1>Password change</h1>')

        response = password_change_done(request)
        self.assertContains(response,
                            '<title>Password change successful</title>')
        self.assertContains(response, '<h1>Password change successful</h1>')
Exemplo n.º 48
0
def password_reset(request):
    response = auth_views.password_reset(
        request,
        password_reset_form=forms.PasswordResetForm,
        template_name="users/password_reset_form.html",
        email_template_name="registration/password_reset_email.txt",
        subject_template_name="registration/password_reset_subject.txt",
        post_reset_redirect=reverse("home"))

    if response.status_code == 302:
        messages.success(
            request, u"Password reset email sent; check your email."
            u"If you don't receive an email, verify that you are entering the "
            u"email address you signed up with, and try again.")

    return response
Exemplo n.º 49
0
def password_reset(request, *args, **kwargs):
    errorMessage, warningMessage, infoMessage = get_session_messages(request)
    template_response = auth_views.password_reset(request, *args, **kwargs)
    if template_response.status_code == 302:
        # if we redirect, no need to change the response data
        return template_response
    template_response.context_data.update({
        'errorMessage': errorMessage,
        'warningMessage': warningMessage,
        'infoMessage': infoMessage,
        'adminName': adminName,
        'adminEmail': adminEmail,
        'siteVersion': siteVersion,
        'imsVersion': imsVersion,
    })
    return template_response
Exemplo n.º 50
0
def ResetRequest(request):
        if request.method == 'POST':
                form = ResetForm(request.POST)
                if form.is_valid():
                        return password_reset(request, template_name='password_reset_form.html',
                                              email_template_name='password_reset_email.html',
                                              subject_template_name='password_reset_email_subject.html',
                                              post_reset_redirect=reverse('success'))
                        
                else:
                        return render_to_response('password_reset_form.html', {'form': form}, context_instance=RequestContext(request))
        else:
                ''' user is not submitting the form, show the login form '''
                form = ResetForm()
                context = {'form': form}
                return render_to_response('password_reset_form.html', context, context_instance=RequestContext(request))
Exemplo n.º 51
0
def forgot_passwd(request):
    if request.method == 'GET':
        return render(request, 'coursereg/forgotpass.html')
    else:
        user = models.User.objects.filter(email=request.POST['email']).first()
        if user:
            messages.success(request, 'Password recovery email sent.')
            return password_reset(
                request,
                template_name='coursereg/forgotpass.html',
                email_template_name='coursereg/forgotpass_email_body.html',
                subject_template_name='coursereg/forgotpass_email_subject.txt',
                post_reset_redirect=reverse('coursereg:signin'))
        else:
            messages.error(request, 'Unknown user.')
            return redirect(reverse('coursereg:forgot_passwd'))
Exemplo n.º 52
0
def password_reset_view(request):
    extra_context = {'appearance_type': 'plain'}

    return password_reset(
        request,
        extra_context=extra_context,
        email_template_name='authentication/password_reset_email.html',
        extra_email_context={
            'project_title': settings.PROJECT_TITLE,
            'project_website': settings.PROJECT_WEBSITE,
            'project_copyright': settings.PROJECT_COPYRIGHT,
            'project_license': settings.PROJECT_LICENSE,
        },
        subject_template_name='authentication/password_reset_subject.txt',
        template_name='authentication/password_reset_form.html',
        post_reset_redirect=reverse('authentication:password_reset_done_view'))
Exemplo n.º 53
0
def password_reset_view(request):
    extra_context = {'appearance_type': 'plain'}

    return password_reset(
        request,
        extra_context=extra_context,
        email_template_name='authentication/password_reset_email.html',
        extra_email_context={
            'project_title': setting_project_title.value,
            'project_website': mayan.__website__,
            'project_copyright': mayan.__copyright__,
            'project_license': mayan.__license__,
        },
        subject_template_name='authentication/password_reset_subject.txt',
        template_name='authentication/password_reset_form.html',
        post_reset_redirect=reverse('authentication:password_reset_done_view'))
Exemplo n.º 54
0
def password_reset_error(request, *args, **kwargs):
    if request.method == "POST":
        eml = request.POST.get('email', None)
        if eml:
            obju = User.objects.filter(email=eml)
            print "object=", obju
            if not obju:
                return HttpResponseRedirect(reverse('password_reset_error'))
            else:
                return password_reset(request, *args, **kwargs)
    password_reset_form = PasswordResetForm
    form = password_reset_form()
    template_name = "registration/password_reset_error_form.html"
    context = {
        'form': form,
    }
    return TemplateResponse(request, template_name, context)
Exemplo n.º 55
0
def retrieve_new_password(request):

    if request.method == 'POST':
        email = request.POST['email']
        try:
            verified_email = Email.objects.get(email=email,
                                               email_is_verified=True)
            return password_reset(request)
        except Email.DoesNotExist:
            return render_to_response('retrieve_new_password.html', {
                'errors':
                'The email you entered was not found or it has never been verified'
            },
                                      context_instance=RequestContext(request))
    else:
        return render_to_response('retrieve_new_password.html',
                                  context_instance=RequestContext(request))
Exemplo n.º 56
0
def reset_form(request):
    try:
        protocol = request.META.get('HTTP_X_FORWARDED_PROTOCOL', 'http')
        extra_email_context = {'request': request, 'protocol': protocol}

        return auth_views.password_reset(
            request,
            password_reset_form=forms.PasswordResetForm,  # Custom Form
            post_reset_redirect='password/reset/accepted',
            template_name='accounts/password/reset/form.html',
            extra_email_context=extra_email_context,
            **conf.PASSWORD_RESET_PARAMS)

    except:
        logger.error(traceback.format_exc())
        return render(request, 'accounts/password/reset/error.html',
                      dict(ex=_('Failed to send password reset error')))
Exemplo n.º 57
0
def password_reset_proxy(request, *args, **kwargs):
    """ Proxies the django.contrib.auth view. Only send a password reset mail
        if the email doesn't belong to a user that is a member of an integrated portal. """
    if request.method == 'POST':
        email = request.POST.get('email', None)
        user = None
        if email:
            try:
                user = USER_MODEL.objects.get(email=email, is_active=True)
            except USER_MODEL.DoesNotExist:
                pass
        if user and check_user_integrated_portal_member(user):
            return TemplateResponse(request, 'cosinnus/registration/password_cannot_be_reset_page.html')
    kwargs.update({
        'password_reset_form': CosinnusPasswordResetForm,
    })
    return password_reset(request, *args, **kwargs)
Exemplo n.º 58
0
def forgot_passwd(request):
    """
    User password reset page.
    """
    dc_settings = request.dc.settings
    return password_reset(
        request,
        template_name='gui/accounts/forgot.html',
        email_template_name='gui/accounts/forgot_email.txt',
        subject_template_name='gui/accounts/forgot_subject.txt',
        password_reset_form=partial(ForgotForm, request),
        post_reset_redirect=reverse('forgot_done'),
        from_email=dc_settings.DEFAULT_FROM_EMAIL,
        current_app='gui',
        extra_context={
            'e_site_name': dc_settings.SITE_NAME,
            'e_site_link': dc_settings.SITE_LINK,
        })
Exemplo n.º 59
0
    def post(request):
        email = request.POST.get('email', '')
        request.session['reset_email'] = email

        # Seo
        seo = Seo()
        seo.title = _('Password reset')
        seo.save(request)

        return password_reset(
            request,
            template_name='users/reset.html',
            password_reset_form=PasswordResetForm,
            post_reset_redirect='users:reset_done',
            email_template_name='users/emails/reset_email.html',
            html_email_template_name='users/emails/reset_email.html',
            subject_template_name='users/emails/reset_subject.html',
        )
Exemplo n.º 60
0
def password_reset2(request):
    """
        django.contrib.auth.views.password_reset view (forgotten password)
        """
    if not request.user.is_authenticated():
        print "entro a password_reset2"
        try:
            return password_reset(
                request,
                template_name='password_reset_form.html',
                email_template_name='password_reset_email.html',
                subject_template_name='password_reset_subject.txt',
                post_reset_redirect=reverse("password_reset_done2"))
        except Exception:
            return HttpResponseRedirect(reverse("password_reset_done2"))
    else:
        print "no entro a password_reset2"
        return HttpResponseRedirect(reverse("personal_data"))