def get_next_url_for_login_page(request):
 redirect_to = request.GET.get('next', None)
 if (redirect_to and (not http.is_safe_url(redirect_to))):
  log.error(u'Unsafe redirect parameter detected: %(redirect_to)r', {'redirect_to': redirect_to})
  redirect_to = None
 if (not redirect_to):
  try:
   redirect_to = reverse('dashboard')
  except NoReverseMatch:
   redirect_to = reverse('home')
 if any(((param in request.GET) for param in POST_AUTH_PARAMS)):
  params = [(param, request.GET[param]) for param in POST_AUTH_PARAMS if (param in request.GET)]
  params.append(('next', redirect_to))
  redirect_to = '{}?{}'.format(reverse('finish_auth'), urllib.urlencode(params))
 return redirect_to

def get_next_url_for_login_page ( request ) : redirect_to = request . GET . get ( 'next' , None ) if ( redirect_to and ( not http . is_safe_url ( redirect_to ) ) ) : log . error ( u'Unsafe redirect parameter detected: %(redirect_to)r' , { 'redirect_to' : redirect_to } ) redirect_to = None if ( not redirect_to ) : try : redirect_to = reverse ( 'dashboard' ) except NoReverseMatch : redirect_to = reverse ( 'home' ) if any ( ( ( param in request . GET ) for param in POST_AUTH_PARAMS ) ) : params = [ ( param , request . GET [ param ] ) for param in POST_AUTH_PARAMS if ( param in request . GET ) ] params . append ( ( 'next' , redirect_to ) ) redirect_to = '{}?{}' . format ( reverse ( 'finish_auth' ) , urllib . urlencode ( params ) ) return redirect_to
determine the url to redirect to following login/registration/third_party_auth the user is currently on a login or registration page .