@require_http_methods(['POST'])
def password_change_request_handler(request):
 limiter = BadRequestRateLimiter()
 if limiter.is_rate_limit_exceeded(request):
  AUDIT_LOG.warning('Password reset rate limit exceeded')
  return HttpResponseForbidden()
 user = request.user
 email = (user.email if user.is_authenticated() else request.POST.get('email'))
 if email:
  try:
   request_password_change(email, request.get_host(), request.is_secure())
   user = (user if user.is_authenticated() else User.objects.get(email=email))
   destroy_oauth_tokens(user)
  except UserNotFound:
   AUDIT_LOG.info('Invalid password reset attempt')
   limiter.tick_bad_request_counter(request)
  return HttpResponse(status=200)
 else:
  return HttpResponseBadRequest(_('No email address provided.'))

@ require_http_methods ( [ 'POST' ] ) def password_change_request_handler ( request ) : limiter = BadRequestRateLimiter ( ) if limiter . is_rate_limit_exceeded ( request ) : AUDIT_LOG . warning ( 'Password reset rate limit exceeded' ) return HttpResponseForbidden ( ) user = request . user email = ( user . email if user . is_authenticated ( ) else request . POST . get ( 'email' ) ) if email : try : request_password_change ( email , request . get_host ( ) , request . is_secure ( ) ) user = ( user if user . is_authenticated ( ) else User . objects . get ( email = email ) ) destroy_oauth_tokens ( user ) except UserNotFound : AUDIT_LOG . info ( 'Invalid password reset attempt' ) limiter . tick_bad_request_counter ( request ) return HttpResponse ( status = 200 ) else : return HttpResponseBadRequest ( _ ( 'No email address provided.' ) )
handle password change requests originating from the account page .