Module: Platforms::Core::OAuth2

Extended by:
ActiveSupport::Concern
Defined in:
lib/platforms/core/o_auth_2.rb

Overview

This is a module for common authentication methods, across multiple platforms.

Instance Method Summary collapse

Instance Method Details

#bool_safe(val) ⇒ Object

Sometimes the return value is a string “true”, while others it is cast as a boolean. This normalises that behaviour to true or false. Any non-“true” String value should return false.

Parameters:

  • val (Object)

    value to convert

Returns:

  • boolean equivalent



21
22
23
24
# File 'lib/platforms/core/o_auth_2.rb', line 21

def bool_safe val
  return val == "true" if val.is_a? String
  val.eql?(true)
end

#tokenObject

Get the token from the OmniAuth credentials store A convenience method.

Returns:

  • the OmniAuth auth token



12
13
14
# File 'lib/platforms/core/o_auth_2.rb', line 12

def token
  request.env["omniauth.auth"].credentials.token
end