Make adding and removing master device operations.
// FREEBIE
This commit is contained in:
parent
52ce7d6935
commit
fb411b20cc
|
@ -94,6 +94,10 @@ public class DeviceController {
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/{device_id}")
|
@Path("/{device_id}")
|
||||||
public void removeDevice(@Auth Account account, @PathParam("device_id") long deviceId) {
|
public void removeDevice(@Auth Account account, @PathParam("device_id") long deviceId) {
|
||||||
|
if (account.getAuthenticatedDevice().get().getId() != Device.MASTER_ID) {
|
||||||
|
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
|
||||||
account.removeDevice(deviceId);
|
account.removeDevice(deviceId);
|
||||||
accounts.update(account);
|
accounts.update(account);
|
||||||
}
|
}
|
||||||
|
@ -111,6 +115,10 @@ public class DeviceController {
|
||||||
throw new DeviceLimitExceededException(account.getDevices().size(), MAX_DEVICES);
|
throw new DeviceLimitExceededException(account.getDevices().size(), MAX_DEVICES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (account.getAuthenticatedDevice().get().getId() != Device.MASTER_ID) {
|
||||||
|
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
|
||||||
VerificationCode verificationCode = generateVerificationCode();
|
VerificationCode verificationCode = generateVerificationCode();
|
||||||
pendingDevices.store(account.getNumber(), verificationCode.getVerificationCode());
|
pendingDevices.store(account.getNumber(), verificationCode.getVerificationCode());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue