Module: SocialStream::Oauth2Server::Models::User

Extended by:
ActiveSupport::Concern
Defined in:
lib/social_stream/oauth2_server/models/user.rb

Instance Method Summary collapse

Instance Method Details

#as_json_with_client(options = {}) ⇒ Object

Include application role information in the json



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/social_stream/oauth2_server/models/user.rb', line 36

def as_json_with_client options = {}
  hash = as_json_without_client options

  if options[:client] && !options[:client].is_a?(User)
    hash['roles'] = options[:client].contact_to!(self).relations.map{ |r|
      { 
        id: r.id,
        name: r.name
      }
    }
  end

  hash
end

#client_authorize!(client) ⇒ Object

Create a new tie to Site::Client



29
30
31
32
33
# File 'lib/social_stream/oauth2_server/models/user.rb', line 29

def client_authorize!(client)
  unless contact_to!(client).relation_ids.include?(Relation::Auth.instance.id)
    contact_to!(client).relation_ids += [ Relation::Auth.instance.id ]
  end
end

#client_authorized?(client) ⇒ Boolean

Is #client authorized by this SocialStream::Oauth2Server::Models::User

Returns:

  • (Boolean)


24
25
26
# File 'lib/social_stream/oauth2_server/models/user.rb', line 24

def client_authorized?(client)
  contact_to!(client).relation_ids.include? Relation::Auth.instance.id
end