如代码所示:
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def github
@user = User.find_for_github_oauth(request.env["omniauth.auth"], current_user)
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "GitHub" if is_navigational_format?
sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
else
session["devise.github_data"] = request.env["omniauth.auth"]
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "GitHub" if is_navigational_format?
redirect_to new_user_registration_url
end
end
end
这一行:
...
session["devise.github_data"] = request.env["omniauth.auth"]
...
会把一个巨大无比的 github oauth 信息放到 session 中,这个直接会让 cookie overflow。
由于不想把 session 存到内存里面,请问这个有必要这样写吗?有什么解决方案没有?