diff --git a/lib/doorkeeper/request/authorization_code.rb b/lib/doorkeeper/request/authorization_code.rb index 9b5d74eec..5c49870e0 100644 --- a/lib/doorkeeper/request/authorization_code.rb +++ b/lib/doorkeeper/request/authorization_code.rb @@ -3,15 +3,10 @@ module Doorkeeper module Request class AuthorizationCode < Strategy - attr_accessor :grant, :client - - def initialize(server) - super - @grant, @client = server.grant, server.client - end + delegate :grant, :client, :parameters, to: :server def request - @request ||= OAuth::AuthorizationCodeRequest.new(Doorkeeper.configuration, grant, client, server.parameters) + @request ||= OAuth::AuthorizationCodeRequest.new(Doorkeeper.configuration, grant, client, parameters) end end end diff --git a/lib/doorkeeper/request/client_credentials.rb b/lib/doorkeeper/request/client_credentials.rb index e65b3467e..e41ceaa11 100644 --- a/lib/doorkeeper/request/client_credentials.rb +++ b/lib/doorkeeper/request/client_credentials.rb @@ -3,15 +3,10 @@ module Doorkeeper module Request class ClientCredentials < Strategy - attr_accessor :client - - def initialize(server) - super - @client = server.client - end + delegate :client, :parameters, to: :server def request - @request ||= OAuth::ClientCredentialsRequest.new(Doorkeeper.configuration, client, server.parameters) + @request ||= OAuth::ClientCredentialsRequest.new(Doorkeeper.configuration, client, parameters) end end end diff --git a/lib/doorkeeper/request/code.rb b/lib/doorkeeper/request/code.rb index c3e045c6e..606f64611 100644 --- a/lib/doorkeeper/request/code.rb +++ b/lib/doorkeeper/request/code.rb @@ -3,15 +3,14 @@ module Doorkeeper module Request class Code < Strategy - attr_accessor :pre_auth + delegate :current_resource_owner, to: :server - def initialize(server) - super - @pre_auth = server.context.send(:pre_auth) + def pre_auth + server.context.send(:pre_auth) end def request - @request ||= OAuth::CodeRequest.new(pre_auth, server.current_resource_owner) + @request ||= OAuth::CodeRequest.new(pre_auth, current_resource_owner) end end end diff --git a/lib/doorkeeper/request/password.rb b/lib/doorkeeper/request/password.rb index 977eb0fa3..86f1a4f8e 100644 --- a/lib/doorkeeper/request/password.rb +++ b/lib/doorkeeper/request/password.rb @@ -3,16 +3,10 @@ module Doorkeeper module Request class Password < Strategy - attr_accessor :credentials, :resource_owner - - def initialize(server) - super - @credentials = server.credentials - @resource_owner = server.resource_owner - end + delegate :credentials, :resource_owner, :parameters, to: :server def request - @request ||= OAuth::PasswordAccessTokenRequest.new(Doorkeeper.configuration, credentials, resource_owner, server.parameters) + @request ||= OAuth::PasswordAccessTokenRequest.new(Doorkeeper.configuration, credentials, resource_owner, parameters) end end end diff --git a/lib/doorkeeper/request/refresh_token.rb b/lib/doorkeeper/request/refresh_token.rb index 159b45d34..d38906988 100644 --- a/lib/doorkeeper/request/refresh_token.rb +++ b/lib/doorkeeper/request/refresh_token.rb @@ -3,16 +3,14 @@ module Doorkeeper module Request class RefreshToken < Strategy - attr_accessor :refresh_token, :credentials + delegate :credentials, :parameters, to: :server - def initialize(server) - super - @refresh_token = server.current_refresh_token - @credentials = server.credentials + def refresh_token + server.current_refresh_token end def request - @request ||= OAuth::RefreshTokenRequest.new(Doorkeeper.configuration, refresh_token, credentials, server.parameters) + @request ||= OAuth::RefreshTokenRequest.new(Doorkeeper.configuration, refresh_token, credentials, parameters) end end end diff --git a/lib/doorkeeper/request/token.rb b/lib/doorkeeper/request/token.rb index 55e398d44..bc542da44 100644 --- a/lib/doorkeeper/request/token.rb +++ b/lib/doorkeeper/request/token.rb @@ -3,15 +3,14 @@ module Doorkeeper module Request class Token < Strategy - attr_accessor :pre_auth + delegate :current_resource_owner, to: :server - def initialize(server) - super - @pre_auth = server.context.send(:pre_auth) + def pre_auth + server.context.send(:pre_auth) end def request - @request ||= OAuth::TokenRequest.new(pre_auth, server.current_resource_owner) + @request ||= OAuth::TokenRequest.new(pre_auth, current_resource_owner) end end end