Sha256: 0360f5111a0da2b61cfab8994ae842e509af0ba3cda6c5fa8586843c6528ca5c

Contents?: true

Size: 805 Bytes

Versions: 1

Compression:

Stored size: 805 Bytes

Contents

module DeviseOnesignal
    module DeviceConcern

        extend ActiveSupport::Concern

        extend DeviseOnesignal::DeviceHelper

        included do
            before_action :set_device
        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

        def set_device_owner
            current_user if current_user
        end

    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise-onesignal-3.0.0 lib/devise-onesignal/device_concern.rb