Class: Leash::Provider::AuthorizeController
- Inherits:
-
Leash::ProviderController
- Object
- ActionController::Base
- LeashController
- Leash::ProviderController
- Leash::Provider::AuthorizeController
- Defined in:
- app/controllers/leash/provider/authorize_controller.rb
Constant Summary collapse
- RESPONSE_TYPES =
[ "token", "code" ].freeze
Constants inherited from Leash::ProviderController
Leash::ProviderController::CLIENT_ID_REGEXP
Instance Method Summary collapse
Instance Method Details
#authorize ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/leash/provider/authorize_controller.rb', line 11 def case @response_type when "token" if Leash::Provider.reuse_access_tokens == true access_token_obj = Leash::Provider::AccessToken.find_by_app_name_and_owner @app_name, current_owner if access_token_obj access_token = access_token_obj.access_token else access_token = Leash::Provider::AccessToken.assign! @app_name, current_owner end else access_token = Leash::Provider::AccessToken.assign! @app_name, current_owner end Rails.logger.info "[Leash::Provider] Authorize ok: response_type=#{@response_type} app_name=#{@app_name} current_owner=#{current_owner.class.name}##{current_owner.id} access_token=#{access_token} request_ip=#{request.remote_ip} request_user_agent=#{request.user_agent}" redirect_to params[:redirect_uri] + "#access_token=#{URI.encode(access_token)}" when "code" auth_code = Leash::Provider::AuthCode.assign! @app_name, current_owner Rails.logger.info "[Leash::Provider] Authorize ok: response_type=#{@response_type} current_owner=#{current_owner.class.name}##{current_owner.id} auth_code=#{auth_code} request_ip=#{request.remote_ip} request_user_agent=#{request.user_agent}" if params.has_key? :state redirect_to params[:redirect_uri] + "?code=#{URI.encode(auth_code)}&state=#{URI.encode(params[:state])}" else redirect_to params[:redirect_uri] + "?code=#{URI.encode(auth_code)}" end else fail "Should not be reached" end end |