Make adding and removing master device operations.

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2015-06-22 11:01:08 -07:00
parent 52ce7d6935
commit fb411b20cc
1 changed files with 8 additions and 0 deletions

View File

@ -94,6 +94,10 @@ public class DeviceController {
@DELETE
@Path("/{device_id}")
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);
accounts.update(account);
}
@ -111,6 +115,10 @@ public class DeviceController {
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();
pendingDevices.store(account.getNumber(), verificationCode.getVerificationCode());