Sha256: 0d190ae2d991122dfba780cd5601a68518be7ae9b63e97c4b0c4773f9bc8ce77

Contents?: true

Size: 805 Bytes

Versions: 5

Compression:

Stored size: 805 Bytes

Contents

module DeviseOnesignal
    module DeviceConcern

        extend ActiveSupport::Concern

        extend DeviseOnesignal::DeviceHelper

        included do
            before_action :set_device
        end

        def set_device_owner
            current_user if current_user
        end

        private

        def set_device
            unless cookies[:oneSignalPlayerId].nil?
                onesignal_player_id = cookies[:oneSignalPlayerId]
                device = Device.find_or_create_by! onesignal_id: onesignal_player_id
                device.onesignal_permission = cookies[:oneSignalPlayerPermission]
                device.last_used = Time.now
                device.owner = set_device_owner
                device.save!
            end
        end

    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
devise-onesignal-4.0.1 lib/devise-onesignal/device_concern.rb
devise-onesignal-4.0.0 lib/devise-onesignal/device_concern.rb
devise-onesignal-3.2.0 lib/devise-onesignal/device_concern.rb
devise-onesignal-3.1.5 lib/devise-onesignal/device_concern.rb
devise-onesignal-3.1.4 lib/devise-onesignal/device_concern.rb