示例#1
0
def password_reset_confirm(request, uidb64=None, token=None):
    if request.method == 'GET' or not request.is_ajax():
        template_response = views.password_reset_confirm(request, uidb64=uidb64, token=token,template_name='beta/reset/password_reset_confirm.html')
        return template_response
    else:
        print('ajax')
        template_response = views.password_reset_confirm(request, template_name='beta/reset/password_reset_confirm.html')
        return template_response
    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>')
示例#3
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        uidb64=uidb64,
        template_name='dashboard/user_management/reset_confirm.html',
        token=token,
        post_reset_redirect=reverse('success'))
示例#4
0
    def post(self, request, uidb64=None, token=None):
        # Seo
        seo = Seo()
        seo.title = _('Password reset')
        seo.save(request)

        if request.user.is_authenticated():
            # Смена своего пароля, если авторизованы
            form = SetPasswordForm(request.user, request.POST)
            if form.is_valid():
                form.save()
                return redirect(
                    get_redirect_url(request, 'users:reset_complete'))
            else:
                return self.render_to_response({
                    'form': form,
                })
        else:
            if uidb64 is None or token is None:
                return redirect(
                    resolve_url(settings.RESET_PASSWORD_REDIRECT_URL))

            return password_reset_confirm(
                request,
                uidb64=uidb64,
                token=token,
                template_name='users/reset_confirm.html',
                set_password_form=SetPasswordForm,
                post_reset_redirect='users:reset_complete',
            )
示例#5
0
    def get(self, request, uidb64=None, token=None):
        if request.user.is_authenticated():
            return redirect(get_redirect_url(request))

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

        try:
            uid = urlsafe_base64_decode(uidb64)
            user = UserModel._default_manager.get(pk=uid)
        except (TypeError, ValueError, OverflowError, ObjectDoesNotExist):
            user = None

        if user is None or not default_token_generator.check_token(
                user, token):
            return redirect(resolve_url(settings.RESET_PASSWORD_REDIRECT_URL))

        return password_reset_confirm(
            request,
            uidb64=uidb64,
            token=token,
            template_name='users/reset_confirm.html',
            set_password_form=SetPasswordForm,
            post_reset_redirect='users:reset_complete',
        )
示例#6
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        template_name='registration/password_reset_confirm.html',
        uidb64=uidb64,
        token=token,
    )
示例#7
0
def reset_confirm (request, uidb64=None, token=None):
    """
    Display form for resetting password (link sent in email).
    """
    return password_reset_confirm(request, template_name = 'reset_confirm.html',
                                  uidb64 = uidb64, token = token,
                                  post_reset_redirect = reverse('password_reset_success'))
示例#8
0
def reset_confirm(request, uidb36=None, token=None):
    template = password_reset_confirm(request,
                                      template_name='app/reset_confirm.html',
                                      uidb36=uidb36,
                                      token=token,
                                      post_reset_redirect=reverse('app:login'))
    return template
示例#9
0
def register_email_confirm(
        request,
        uidb36=None,
        token=None,
        template_name='registration/password_reset_confirm.html',
        token_generator=default_token_generator,
        set_password_form=SetPasswordForm,
        post_reset_redirect=None,
        current_app=None,
        extra_context=None):
    # Mostly copied from django auth views
    assert uidb36 is not None and token is not None  # checked by URLconf
    try:
        uid_int = base36_to_int(uidb36)
        user = User.objects.get(id=uid_int)
    except (ValueError, User.DoesNotExist):
        user = None

    if user is not None and token_generator.check_token(user, token):
        # valid link. confirm the email.
        handsomely_user = HandsomelyUser.objects.get(django_user=user)
        handsomely_user.confirmed = True
        handsomely_user.save()

    # Go to the set password page to let it handle the rest (even if link is invalid)
    return password_reset_confirm(
        request,
        uidb36,
        token,
        template_name="registration/register_password.html",
        post_reset_redirect="/status")
示例#10
0
def recover_confirm(request, uidb64, token):
    return password_reset_confirm(
        request,
        uidb64=uidb64,
        token=token,
        template_name="accounts/recover_confirm.html",
        post_reset_redirect=reverse(login))
示例#11
0
文件: views.py 项目: aklaver/pgweb
def reset_confirm(request, uidb36, token):
	log.info("Confirming password reset for uidb {0}, token {1} from {2}".format(uidb36, token, get_client_ip(request)))
	return authviews.password_reset_confirm(request,
											uidb36=uidb36,
											token=token,
											template_name='account/password_reset_confirm.html',
											post_reset_redirect='/account/reset/complete/')
示例#12
0
文件: views.py 项目: chicosilva/csms
def restaurar_senha(request, uidb64=None, token=None):

    if request.method == 'POST':
        messages.success(request, u'Senha alterada com sucesso!')

    return password_reset_confirm(request, template_name='autenticacao/reset_confirm.html',
        uidb64=uidb64, token=token, post_reset_redirect=reverse('autenticacao:login'))
示例#13
0
def account_confirm(request, uidb64=None, token=None):
	return password_reset_confirm(
		request,
		template_name='account_confirmation_form.html',
		uidb64=uidb64,
		token=token,
		post_reset_redirect='/events/new/')
示例#14
0
 def get(self, request, *args, **kwargs):
     extra_context = kwargs.setdefault('extra_context', {})
     extra_context[
         'hide_password_feedback'] = settings.ENABLE_DRACONIAN_SECURITY_FEATURES
     extra_context[
         'implement_password_obfuscation'] = settings.OBFUSCATE_PASSWORD_FOR_NIC_COMPLIANCE
     return password_reset_confirm(request, *args, **kwargs)
示例#15
0
文件: views.py 项目: lisafbe/SIGIA
	def dispatch(self,request,*args,**kwargs):
		
		return password_reset_confirm(
			request,
			template_name = 'inicio/recuperar_login_confirmacion.html',
			uidb64=kwargs['uidb64'], token=kwargs['token'], 
			post_reset_redirect=reverse('inicio:recuperar_login_terminado'))
示例#16
0
文件: views.py 项目: cgvarela/esdc-ce
def forgot_passwd_check(request, uidb64=None, token=None):
    """
    Page that checks the hash in a password reset link, generates a new password which is send via SMS to the user.
    """
    assert uidb64 is not None and token is not None

    try:
        user = User.objects.get(id=urlsafe_base64_decode(uidb64))
        profile = user.userprofile
    except (ValueError, OverflowError, User.DoesNotExist):
        profile = None

    if profile and profile.email_token == token:
        # Email address is verified, we cant compare to token as register token is different to reset one.
        profile.email_token = ''
        profile.email_verified = True
        # This may look strange - setting the phone_verified before the user logs in. It is not :) We are sending new
        # password to phone number in profile, after the user logs in we would set phone_verified to True anyway.
        profile.phone_verified = True
        profile.save()

    return password_reset_confirm(
        request,
        uidb64=uidb64,
        token=token,
        template_name='gui/accounts/forgot_check.html',
        set_password_form=PasswordResetForm,
        post_reset_redirect=reverse('forgot_check_done'),
        current_app='gui')
示例#17
0
def reset_confirm(request, uidb36=None, token=None):
    return password_reset_confirm(
        request,
        template_name='registration/password_reset_confirm.html',
        uidb36=uidb36,
        token=token,
        post_reset_redirect=reverse('cabinet:login'))
示例#18
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        # template_name='grumblr/reset_confirm.html',
        uidb64=uidb64,
        token=token,
        post_reset_redirect=reverse('login'))
示例#19
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(request,
                                  template_name='tethys_portal/accounts/password_reset/reset_confirm.html',
                                  uidb64=uidb64,
                                  token=token,
                                  post_reset_redirect=reverse('accounts:login')
    )
示例#20
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        template_name='account/reset-password-confirm.html',
        uidb64=uidb64,
        token=token,
        post_reset_redirect=reverse('signin'))
示例#21
0
def reset_password_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request=request,
        template_name='auth/reset_password_confirm.html',
        uidb64=uidb64,
        token=token,
        post_reset_redirect='auth-login')
示例#22
0
def password_reset_confirm(request, *args, **kwargs):
    old_base36_to_int = http_utils.base36_to_int
    old_user = auth_views.User

    def base36_to_objectid(s):
        if 13 < len(s) <= 26:
            return bson.ObjectId(hex(int(s, 36))[2:-1])
        else:
            return old_base36_to_int(s)

    http.base36_to_int = base36_to_objectid
    auth_views.base36_to_int = base36_to_objectid
    auth_views.User = backends.User
    try:
        result = auth_views.password_reset_confirm(request, *args, **kwargs)
        if isinstance(result, http.HttpResponseRedirect):
            messages.success(
                request,
                _("Your password has been set. You may go ahead and login now."
                  ))
        return result
    finally:
        http.base36_to_int = old_base36_to_int
        auth_views.base36_to_int = old_base36_to_int
        auth_views.User = old_user
示例#23
0
文件: views.py 项目: yosufali/wbp
def reset_confirm(request, uidb64=None, token=None):
	'''
	This is a method that is used by Django's password reset functionality and is triggered
	by the password_reset method when a when the password is successfully reset.
	'''

	return password_reset_confirm(request, uidb64=uidb36, token=token, post_reset_redirect=reverse('index'))
示例#24
0
 def delegate_password_reset_confirm_render(request, template, context=None, status=200):
     return djauth_views.password_reset_confirm(
         request,
         uidb64,
         token,
         template_name=template,
         extra_context=context)
示例#25
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        template_name='registration/password_reset_confirm.html',
        uidb64=uidb64,
        token=token,
    )
示例#26
0
def reset_confirm(request, uidb64, token):
	log.info("Confirming password reset for uidb {0}, token {1} from {2}".format(uidb64, token, get_client_ip(request)))
	return authviews.password_reset_confirm(request,
											uidb64=uidb64,
											token=token,
											template_name='account/password_reset_confirm.html',
											post_reset_redirect='/account/reset/complete/')
示例#27
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        template_name='registration/reset_password_confirm.html',
        uidb64=uidb64,
        token=token,
        post_reset_redirect=reverse('app_mgr:login'))
示例#28
0
def email_password_reset_confirm(request,uidb64=None, token=None):
	context = {}
	return password_reset_confirm(request,uidb64=uidb64, token = token,
									template_name='password_reset.html',
									set_password_form= EmailResetPasswordForm,
									post_reset_redirect= 'email-password-reset-complete',
									extra_context = {'regis_form':RegistrationForm,'search_form':SearchForm,'login_form':LoginForm})
示例#29
0
    def post(self, request, uidb64=None, token=None):
        if request.POST.get('new_password1') != request.POST.get('new_password2'):
            raise ValidationError("Passwords don't match")


        """
        View that checks the hash in a password reset link and presents a
        form for entering a new password.
        """
        UserModel = get_user_model()
        assert uidb64 is not None and token is not None  # checked by URLconf
        try:
            # urlsafe_base64_decode() decodes to bytestring on Python 3
            uid = force_text(urlsafe_base64_decode(uidb64))
            user = UserModel._default_manager.get(pk=uid)
        except (UserModel.DoesNotExist):
            user = None


        # si el link aún es válido
        #Hack to avoid csrf_protect
        if user is not None and default_token_generator.check_token(user, token):

            request.csrf_processing_done = True
            response = password_reset_confirm(
                request._request,
                uidb64=uidb64,
                token=token)
            
            if type(response) is HttpResponseRedirect:
                return Response({'msg': "Su contraseña ha sido establecida. Ahora puede seguir adelante e iniciar sesión."})

        else:
            return Response({'msg': "El enlace de restablecimiento de contraseña era invalido, seguramente por haberse utilizado previamente. Por favor, solicite un nuevo restablecimiento de contraseña."})
示例#30
0
def cust_password_reset_confirm(request, uidb36=None, token=None):   
    if not request.user.is_authenticated():
        return password_reset_confirm(request, uidb36=uidb36, token=token,
            template_name='registration/password_reset_confirm.html',
            post_reset_redirect='reset2/done/')
    else:
        return HttpResponseRedirect("/")
示例#31
0
def password_reset_confirm(*args, **kwargs):
    from django.contrib.auth import views
    return views.password_reset_confirm(
        *args,
        post_reset_redirect=reverse('login'),
        template_name='password_reset_confirm.html',
        **kwargs)
示例#32
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        template_name='data/data_password_reset_confirm.html',
        uidb64=uidb64,
        token=token,
        post_reset_redirect=reverse('data:reset_complete'))
示例#33
0
 def delegate_password_reset_confirm_render(request, template, context=None, status=200):
     return djauth_views.password_reset_confirm(
         request,
         uidb64,
         token,
         template_name=template,
         extra_context=context)
示例#34
0
def reset_confirm(request, uidb64=None, token=None):
    # Wrap the built-in reset confirmation view and pass to it all the captured parameters like uidb64, token
    # and template name, url to redirect after password reset is confirmed.
    return password_reset_confirm(
        request,  # template_name='dashboard/user_management/reset_confirm.html',
        token=token,
        post_reset_redirect=reverse('success'))
示例#35
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(request,
                                  template_name='shop/reset_confirm.html',
                                  uidb64=uidb64,
                                  token=token,
                                  post_reset_redirect=\
                                  '\../../../../reset/done/')
示例#36
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(request,
                                  uidb64,
                                  token,
                                  set_password_form=SetPasswordForm,
                                  template_name='employees/resetconfirm.html',
                                  post_reset_redirect='reset_complete')
示例#37
0
def password_reset__confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        template_name='eees/password_reset_confirm.html',
        uidb64=uidb64,
        token=token,
        post_reset_redirect=reverse('eees:password_reset__complete'))
示例#38
0
文件: views.py 项目: dorismeixing/KD
def reset_confirm(request, uidb36=None, token=None):
    return password_reset_confirm(
        request,
        template_name='kd/password_reset_confirmation.html',
        uidb36=uidb36,
        token=token,
        post_reset_redirect=reverse('login'))
示例#39
0
def forgot_password(request):
    if 'status' in request.GET:
        if request.GET['status'] == 'done':
            return password_reset_done(request,
                                       'accounts/forgot_password.html',
                                       {'done': True})
        elif request.GET['status'] == 'confirm':
            return password_reset_confirm(
                request,
                request.GET['uid'],
                request.GET['token'],
                'accounts/forgot_password.html',
                extra_context={'confirm': True},
                post_reset_redirect='/accounts/forgot_password?status=complete'
            )
        elif request.GET['status'] == 'complete':
            return password_reset_complete(request,
                                           'accounts/forgot_password.html',
                                           {'complete': True})
    else:
        return password_reset(
            request,
            'accounts/forgot_password.html',
            post_reset_redirect='/accounts/forgot_password?status=done',
            email_template_name='accounts/reset_password_email.html',
            subject_template_name='accounts/reset_password_email_subject.txt')
示例#40
0
def reset_password_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        template_name='powermonitorweb/reset_password_confirm.html',
        uidb64=uidb64,
        token=token,
        post_reset_redirect=reverse('powermonitorweb:reset_password_complete'))
示例#41
0
文件: views.py 项目: samantavm/mPark
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        template_name='registration/password_reset_update_pass.html',
        uidb64=uidb64,
        token=token,
        post_reset_redirect=reverse('reset_complete'))
示例#42
0
 def do_view(self, request, uidb36, token, *args, **kwargs):
     context = super(ResetPasswordComfirmView, self).get_context()
     return password_reset_confirm(request, uidb36, token,
                template_name=self.password_reset_confirm_template,
                token_generator=self.password_reset_token_generator,
                set_password_form=self.password_reset_set_form,
                post_reset_redirect=self.get_admin_url('nadmin_password_reset_complete'),
                current_app=self.admin_site.name, extra_context=context)
示例#43
0
def my_password_reset_confirm(request, uidb36, token):
    return password_reset_confirm(
        request,
        template_name='users/password_confirm.haml',
        uidb36=uidb36,
        token=token,
        extra_context={'e_uidb36': uidb36,
                       'e_token': token})
示例#44
0
def password_reset_confirm(request, uidb64, token):
    """ view that handles the recover password process """
    template_name = "accounts/password_reset_confirm.html"
    success_url = "/accounts/reset/done/"

    return auth_views.password_reset_confirm(request, uidb64, token,
                                             template_name=template_name,
                                             post_reset_redirect=success_url)
def password_reset_confirm(request, *args, **kwargs):
    defaults = {
        'template_name': 'accounts/password_reset_confirm.html',
        'post_reset_redirect': reverse('accounts:password_reset_complete'),
    }
    for key, value in defaults.items():
        kwargs.setdefault(key, value)
    return auth.password_reset_confirm(request, *args, **kwargs)
示例#46
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        template_name="account/reset-password-confirm.html",
        uidb64=uidb64,
        token=token,
        post_reset_redirect=reverse("signin"),
    )
示例#47
0
 def delegate_password_reset_confirm_render(request, template, context=None, status=200):
     return djauth_views.password_reset_confirm(
         request,
         uidb64,
         token,
         template_name=template,
         post_reset_redirect=reverse('tracker:password_reset_complete'),
         extra_context=context)
示例#48
0
def reset_confirm(request, uidb36=None, token=None):  # Call django's password reset function
    return password_reset_confirm(
        request,
        template_name="portal/reset_confirm.html",
        uidb36=uidb36,
        token=token,
        post_reset_redirect=reverse("portal:login"),
    )
示例#49
0
文件: users.py 项目: patacrep/patanet
def reset_password_confirm(request, uidb64, token):
    """A wrapper function for password reset confirmation"""
    return  password_reset_confirm(request,
                    uidb64=uidb64,
                    token=token,
                    template_name='generator/password_reset_confirm.html',
                    post_reset_redirect=reverse('password_reset_complete'),
                    extra_context={'uid': uidb64, 'token': token})
示例#50
0
def cust_password_reset_confirm(request, uidb36, token):
    """ This will allow user to reset his/her password for the system"""
    if not request.user.is_authenticated():
        return password_reset_confirm(request, uidb36=uidb36, token=token,
        template_name='registration/password_reset_confirm.html',
        post_reset_redirect='/recipes/reset/done/')
    else:
        return HttpResponseRedirect("/")  
def reset_password_confirm(request, uidb64=None, token=None,
                           template_name='registration/password_reset_confirm.html',
                           post_reset_redirect=None,
                           current_app=None, extra_context=None):
    return auth_views.password_reset_confirm(request, uidb64=uidb64, token=token,
                           template_name=template_name,
                           post_reset_redirect=post_reset_redirect,
                           current_app=current_app, extra_context=extra_context)
示例#52
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        template_name='password_reset_confirm.html',
        uidb64=uidb64,
        token=token,
        post_reset_redirect=reverse('auth_login')
    )
示例#53
0
def reset_confirm(request, uidb64=None, token=None):
    return password_reset_confirm(
        request,
        template_name='registration/password_reset_confirm.html',
        uidb64=uidb64,
        token=token,
        post_reset_redirect=reverse('accounts:login')
    )
示例#54
0
def password_reset_confirm(request, uidb64=None, token=None):
	template_name = 'account/password_reset_from_key.html'
	post_reset_redirect = 'account_reset_password_complete'
	set_password_form = SetPasswordForm
	return django_views.password_reset_confirm(
		request, uidb64=uidb64, token=token, template_name=template_name,
		post_reset_redirect=post_reset_redirect,
		set_password_form=set_password_form)
示例#55
0
def my_password_reset_confirm_form(request, uidb36, token):
    return password_reset_confirm(
        request,
        template_name="users/ajax/password_confirm_form.haml",
        uidb36=uidb36,
        token=token,
        extra_context={"e_uidb36": uidb36, "e_token": token},
    )
def password_reset_confirm(request):
  uidb64 = request.GET['uidb64']
  token = request.GET['token']
  return djauth_views.password_reset_confirm(request,
    uidb64,
    token,
    template_name='tracker/password_reset_confirm.html',
    extra_context={'event': viewutil.get_event(None), 'csrftoken': get_csrf_token(request)})
示例#57
0
文件: sites.py 项目: bubufox/HomeWork
 def password_reset_confirm(self, request, extra_context=None):
   from django.contrib.auth.views import password_reset_confirm
   url = reverse('site:password_reset_complete')
   defaults = {
     'extra_context': extra_context or {},
     'template_name': 'auth/password_reset_confirm.html',
     'post_reset_redirect': url,
   }
   return password_reset_confirm(request, **defaults)
示例#58
0
def reset_pw_confirm_view(request, uidb64=None, token=None):
    """ View to confirm resetting password. """
    return password_reset_confirm(
        request,
        template_name="reset_confirmation.html",
        uidb64=uidb64,
        token=token,
        post_reset_redirect=reverse("login"),
    )
示例#59
0
def password_reset_confirm(request, uidb64, token):
    u"""Landing page for password reset."""
    return auth_views.password_reset_confirm(
        request,
        uidb64,
        token,
        template_name='auth/password_reset_confirm.html',
        post_reset_redirect='login',
    )