@sensitive_post_parameters()
@never_cache
def password_reset_confirm(request, uidb64=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):
 UserModel = get_user_model()
 assert ((uidb64 is not None) and (token is not None))
 if (post_reset_redirect is None):
  post_reset_redirect = reverse('password_reset_complete')
 else:
  post_reset_redirect = resolve_url(post_reset_redirect)
 try:
  uid = urlsafe_base64_decode(uidb64)
  user = UserModel._default_manager.get(pk=uid)
 except (TypeError, ValueError, OverflowError, UserModel.DoesNotExist):
  user = None
 if ((user is not None) and token_generator.check_token(user, token)):
  validlink = True
  if (request.method == 'POST'):
   form = set_password_form(user, request.POST)
   if form.is_valid():
    form.save()
    return HttpResponseRedirect(post_reset_redirect)
  else:
   form = set_password_form(None)
 else:
  validlink = False
  form = None
 context = {'form': form, 'validlink': validlink}
 if (extra_context is not None):
  context.update(extra_context)
 return TemplateResponse(request, template_name, context, current_app=current_app)

@ sensitive_post_parameters ( ) @ never_cache def password_reset_confirm ( request , uidb64 = 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 ) : UserModel = get_user_model ( ) assert ( ( uidb64 is not None ) and ( token is not None ) ) if ( post_reset_redirect is None ) : post_reset_redirect = reverse ( 'password_reset_complete' ) else : post_reset_redirect = resolve_url ( post_reset_redirect ) try : uid = urlsafe_base64_decode ( uidb64 ) user = UserModel . _default_manager . get ( pk = uid ) except ( TypeError , ValueError , OverflowError , UserModel . DoesNotExist ) : user = None if ( ( user is not None ) and token_generator . check_token ( user , token ) ) : validlink = True if ( request . method == 'POST' ) : form = set_password_form ( user , request . POST ) if form . is_valid ( ) : form . save ( ) return HttpResponseRedirect ( post_reset_redirect ) else : form = set_password_form ( None ) else : validlink = False form = None context = { 'form' : form , 'validlink' : validlink } if ( extra_context is not None ) : context . update ( extra_context ) return TemplateResponse ( request , template_name , context , current_app = current_app )
view that checks the hash in a password reset link and presents a form for entering a new password .