Sha256: 73177228b7704986260b96e58984ba949f5c706e49d14245e5e277b348769777
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
require_dependency 'google_sign_in/redirect_protector' class GoogleSignIn::CallbacksController < GoogleSignIn::BaseController def show redirect_to proceed_to_url, flash: { google_sign_in: google_sign_in_response } rescue GoogleSignIn::RedirectProtector::Violation => error logger.error error.message head :bad_request end private def proceed_to_url flash[:proceed_to].tap { |url| GoogleSignIn::RedirectProtector.ensure_same_origin(url, request.url) } end def google_sign_in_response if valid_request? && params[:code].present? { id_token: id_token } else { error: error_message_for(params[:error]) } end rescue OAuth2::Error => error { error: error_message_for(error.code) } end def valid_request? flash[:state].present? && params[:state] == flash[:state] end def id_token client.auth_code.get_token(params[:code])['id_token'] end def error_message_for(error_code) error_code.presence_in(GoogleSignIn::OAUTH2_ERRORS) || "invalid_request" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
google_sign_in-1.2.0 | app/controllers/google_sign_in/callbacks_controller.rb |