Sha256: 9ac7b0f439b405adb18a6b3adf883a7cb020f0872ab6cb6da95f1fea2f857e1e

Contents?: true

Size: 719 Bytes

Versions: 1

Compression:

Stored size: 719 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[:oneSignalUserId].nil?
                onesignal_user_id = cookies[:oneSignalUserId]
                device = Device.find_or_create_by! onesignal_id: onesignal_user_id
                device.user = current_user if current_user
                device.onesignal_permission = cookies[:oneSignalUserPermission]
                device.last_used = Time.now
                device.save!
            end
        end

    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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