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
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
您当然可以用多行代码来表达,只需将它们放在方括号中即可。
current_user || (session[:after_login_redirect_to] = request.fullpath; redirect_to('/connect'))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.