Class: Api::OpenidConnect::UserInfoController

Inherits:
ApplicationController show all
Includes:
ProtectedResourceEndpoint
Defined in:
app/controllers/api/openid_connect/user_info_controller.rb

Instance Attribute Summary

Attributes included from ProtectedResourceEndpoint

#current_token

Instance Method Summary collapse

Methods included from ProtectedResourceEndpoint

#access_token?, #require_access_token

Instance Method Details

#current_userObject


23
24
25
# File 'app/controllers/api/openid_connect/user_info_controller.rb', line 23

def current_user
  current_token ? current_token.authorization.user : nil
end

#showObject


12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/api/openid_connect/user_info_controller.rb', line 12

def show
  serializer = UserInfoSerializer.new(current_user)
  auth = current_token.authorization
  serializer.serialization_options = {authorization: auth}
  attributes_without_essential =
    serializer.attributes.with_indifferent_access.select {|scope| auth.scopes.include? scope }
  attributes = attributes_without_essential.merge(
    sub: serializer.sub)
  render json: attributes.to_json
end