lib/rodauth/features/oauth_device_grant.rb in rodauth-oauth-0.8.0 vs lib/rodauth/features/oauth_device_grant.rb in rodauth-oauth-0.9.0

- old
+ new

@@ -122,22 +122,21 @@ .to_s(36) # 0 to 9, a to z .upcase .rjust(user_code_size, "0") end - def authorized_oauth_application?(oauth_application, client_secret) + def authorized_oauth_application?(oauth_application, client_secret, _) # skip if using device grant # # requests may be performed by devices with no knowledge of client secret. - return true if !client_secret && oauth_application && use_oauth_device_code_grant_type? + return true if !client_secret && use_oauth_device_code_grant_type? super end def create_oauth_token(grant_type) - case grant_type - when "urn:ietf:params:oauth:grant-type:device_code" + if supported_grant_type?(grant_type, "urn:ietf:params:oauth:grant-type:device_code") throw_json_response_error(invalid_oauth_response_status, "invalid_grant_type") unless use_oauth_device_code_grant_type? oauth_grant = db[oauth_grants_table].where( oauth_grants_code_column => param("device_code"), oauth_grants_oauth_application_id_column => oauth_application[oauth_applications_id_column] @@ -166,10 +165,10 @@ .update(oauth_grants_last_polled_at_column => Sequel::CURRENT_TIMESTAMP) throw_json_response_error(invalid_oauth_response_status, "authorization_pending") end end oauth_token - when "device_code" + elsif grant_type == "device_code" redirect_response_error("invalid_grant_type") unless use_oauth_device_code_grant_type? # fetch oauth grant oauth_grant = db[oauth_grants_table].where( oauth_grants_user_code_column => param("user_code"),