Module: SocialStream::Oauth2Server::Models::User
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/social_stream/oauth2_server/models/user.rb
Instance Method Summary collapse
-
#as_json_with_client(options = {}) ⇒ Object
Include application role information in the json.
-
#client_authorize!(client) ⇒ Object
Create a new tie to Site::Client.
-
#client_authorized?(client) ⇒ Boolean
Is #client authorized by this User.
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 = {} hash = as_json_without_client if [:client] && ![:client].is_a?(User) hash['roles'] = [: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) 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
24 25 26 |
# File 'lib/social_stream/oauth2_server/models/user.rb', line 24 def (client) contact_to!(client).relation_ids.include? Relation::Auth.instance.id end |