lib/devise-onesignal/device_concern.rb in devise-onesignal-2.0.1 vs lib/devise-onesignal/device_concern.rb in devise-onesignal-3.0.0
- old
+ new
@@ -10,17 +10,21 @@
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]
+ 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