module ReportingAPI::TokenAuthenticationConcern
Public Instance Methods
Source
# File app/controllers/concerns/reporting_api/token_authentication_concern.rb, line 60 def decode_jwt!(jwt) if jwt JWT.decode( jwt, Settings.reporting_api.client_app.secret, true, { algorithm: ReportingAPI::OneTimeToken::JWT_SIGNING_ALGORITHM } ) end end
Source
# File app/controllers/concerns/reporting_api/token_authentication_concern.rb, line 71 def touch_sessions!(user) now = Time.zone.now.utc.to_i sessions = ActiveRecord::SessionStore::Session .where( "(data #>> '{}'::text[])::jsonb -> 'value' -> 'warden.user.user.key' -> 0 @> ?::jsonb", [user.id].to_json ) .map do |session| session.data["warden.user.user.session"]["last_request_at"] = now # Unfortunately we need to call a private method here to ensure that # the `data` column on the table is written to. This then allows us # to apply the changes in bulk using `import!` further down. session.send(:serialize_data!) session end ActiveRecord::SessionStore::Session.import!( sessions, on_duplicate_key_update: { conflict_target: %i[id], columns: %i[data] } ) end