module SocialStream::Oauth2Server::Models::User

Public Instance Methods

as_json_with_client(options = {}) click to toggle source

Include application role information in the json

# 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) click to toggle source

Create a new tie to {Site::Client}

# 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) click to toggle source

Is {#client} authorized by this {User}

# 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