Question

I'm using Doorkeeper and if I modify current_user in any way, like put it in a conditional statement using unless or if, Doorkeeper won't pick it up. Is there a simple way I can keep current_user || and fit the next two lines containing the session store and redirect to work in one line to the right of the double pipe?

resource_owner_authenticator do

  current_user ||

  session[:after_login_redirect_to] = request.fullpath
  redirect_to('/connect')   

end
Was it helpful?

Solution 2

You can certainly make an expression out of multiple lines of code, simply wrap them in brackets.

current_user || (session[:after_login_redirect_to] = request.fullpath; redirect_to('/connect'))

OTHER TIPS

No need to make it a one liner - use a begin block:

resource_owner_authenticator do
  current_user || begin
    session[:after_login_redirect_to] = request.fullpath
    redirect_to('/connect')   
  end
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top