Module: Intra::Authenticatable::ClassMethods
- Defined in:
- lib/intra/authenticatable.rb
Instance Method Summary collapse
-
#authenticate(hash) ⇒ Object
process the omniauth hash sent from provider to /oauth/:provider/callback returns an instance of a User.
Instance Method Details
#authenticate(hash) ⇒ Object
process the omniauth hash sent from provider to /oauth/:provider/callback returns an instance of a User
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/intra/authenticatable.rb', line 15 def authenticate(hash) params = { uuid: hash[:provider] + '|' + hash[:uid], email: hash.dig(:info, :email).presence || hash.dig(:info, :name), image_url: hash.dig(:info, :image), remember_token: SecureRandom.hex } Intra.logger.debug 'omniauth response to params=' + params.to_s user = find_by uuid: params[:uuid] if user user.update! params else user = create! params end user end |