deviseを使っていてメールアドレスやパスワードを入力するページは force_ssl をかけていたんだけど、ログイン後のリダイレクトでhttps://hogehoge に飛ばされちゃうと一部の画像とかがssl対応できなかったのでブラウザの判定はイマイチになっちゃう。
そんな時は Devise::SessionsController#create をオーバーライドする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Users::SessionsController < Devise::SessionsController | |
# POST /users/sign_in | |
def create | |
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new") | |
set_flash_message(:notice, :signed_in) if is_navigational_format? | |
sign_in(resource_name, resource) | |
respond_with resource, :location => "http://#{request.host_with_port}#{redirect_location(resource_name, resource)}" | |
end | |
end |
0 コメント:
コメントを投稿