Class: Devise::Strategies::RowndAuthenticatable
- Inherits:
-
Authenticatable
- Object
- Authenticatable
- Devise::Strategies::RowndAuthenticatable
- Defined in:
- lib/devise/rownd/strategies/rownd_authenticatable.rb
Instance Method Summary collapse
-
#authenticate! ⇒ Object
All Strategies must define this method.
- #return_to_after_sign_out ⇒ Object
- #valid? ⇒ Boolean
Instance Method Details
#authenticate! ⇒ Object
All Strategies must define this method.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/devise/rownd/strategies/rownd_authenticatable.rb', line 26 def authenticate! Devise::Rownd::Log.debug('authenticate!') access_token = params[:access_token] Devise::Rownd::Log.error('authenticate! could not proceed. no access token') unless access_token return fail!('No Access Token') unless access_token begin decoded_jwt = ::Devise::Rownd::Token.verify_token(access_token) @app_id = decoded_jwt['aud'].find(/^app:.+/).first.split(':').last configured_app_id = Devise::Rownd.app_id ok = @app_id == configured_app_id unless ok Devise::Rownd::Log.error('authenticate! failed: JWT not authorized for app') return fail!('JWT not authorized for app') end profile = Devise::Rownd::User.fetch_user(access_token) unless profile Devise::Rownd::Log.error('authenticate! failed: Failed to fetch user') fail!('Failed to fetch user') end rownd_user = Devise::Rownd::User.new(profile, access_token) unless rownd_user Devise::Rownd::Log.error('authenticate! failed: failed to initialize user') return fail!('Failed to initialize user') end success!(rownd_user) rescue StandardError => e Devise::Rownd::Log.error("authenticate! failed #{e.}") fail!("Unable to authenticate: #{e.}") end end |
#return_to_after_sign_out ⇒ Object
65 66 67 |
# File 'lib/devise/rownd/strategies/rownd_authenticatable.rb', line 65 def return_to_after_sign_out '/' end |