diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-06-19 01:01:46 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-06-19 01:01:46 +0900 |
commit | 3a21cf8cc21f0f7f56b21e8ebc8e049cabc956ca (patch) | |
tree | 1f76afc1be5c2e289c324fd0220030f4ee46b4ba /app/controllers/application_controller.rb | |
parent | eeaa5ec5230d7a15f1c25ec696caf3a6a0aa5327 (diff) | |
download | aclog-3a21cf8cc21f0f7f56b21e8ebc8e049cabc956ca.tar.gz |
web: extract checking if safe redirect into ApplicationController#safe_redirect?
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7700a2c..15cc108 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,11 +17,10 @@ class ApplicationController < ActionController::Base end def current_user - @_current_user ||= begin + @_current_user ||= if logged_in? User.find(session[:user_id]) end - end end def authorized_to_show_user?(user) @@ -39,4 +38,8 @@ class ApplicationController < ActionController::Base end object end + + def safe_redirect?(to) + to[0] == "/" && !to.include?("//") + end end |