Sha256: 87b66b74df4c190b914e3393ef1001b63c5ef2f099de0747876f0a7e13fd6292
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
require 'restpack_service_messaging' module Commands::Users::User class OmniAuthenticate < RestPack::Service::Command required do integer :application_id hash :omniauth_response do required do string :provider string :uid hash :info end end end optional do integer :user_id end def execute user = Models::Users::User.authenticate( user_id, application_id, raw_inputs[:omniauth_response] ) if user record_activity(user, inputs) return Serializers::Users::User.resource(user) else status :unauthorized end end private def record_activity(user, inputs) provider = inputs[:omniauth_response][:provider] type = 'login' #TODO: GJ: differentiate between login and signup Messaging::Activity::Create.run({ application_id: inputs[:application_id], user_id: user.id, content: "#{user.name} logged in via #{inputs[:omniauth_response][:provider]}", tags: "service:users,auth:#{type},provider:#{provider}" }) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
restpack_user_service-0.0.5 | lib/restpack_user_service/commands/user/omni_authenticate.rb |