From e15c2ffa80e95f90ae9b7c0b29f70e0a2a9993f0 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Thu, 21 Jul 2016 12:14:58 +0200 Subject: [PATCH] allow user to take ownership of a device --- Yavsc/ApiController/GCMController.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Yavsc/ApiController/GCMController.cs b/Yavsc/ApiController/GCMController.cs index 848133a4..10f817b9 100644 --- a/Yavsc/ApiController/GCMController.cs +++ b/Yavsc/ApiController/GCMController.cs @@ -35,10 +35,8 @@ public class GCMController : Controller if (_context.GCMDevices.Any(d => d.DeviceId == declaration.DeviceId)) { var alreadyRegisteredDevice = _context.GCMDevices.FirstOrDefault(d => d.DeviceId == declaration.DeviceId); - if (alreadyRegisteredDevice.DeviceOwnerId != uid) - { - return new BadRequestObjectResult(new { error = $"Device owned by someone else {declaration.DeviceId}" }); - } + // Override an exiting owner + alreadyRegisteredDevice.DeviceOwnerId = uid; alreadyRegisteredDevice.GCMRegistrationId = declaration.GCMRegistrationId; alreadyRegisteredDevice.Model = declaration.Model; alreadyRegisteredDevice.Platform = declaration.Platform;