Disallow registration from clients registered on another relay.
This commit is contained in:
		
							parent
							
								
									129e372613
								
							
						
					
					
						commit
						a63cdc76b0
					
				| 
						 | 
					@ -135,6 +135,10 @@ public class AccountController {
 | 
				
			||||||
        throw new WebApplicationException(Response.status(403).build());
 | 
					        throw new WebApplicationException(Response.status(403).build());
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (accounts.isRelayListed(number)) {
 | 
				
			||||||
 | 
					        throw new WebApplicationException(Response.status(417).build());
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      Device device = new Device();
 | 
					      Device device = new Device();
 | 
				
			||||||
      device.setId(Device.MASTER_ID);
 | 
					      device.setId(Device.MASTER_ID);
 | 
				
			||||||
      device.setAuthenticationCredentials(new AuthenticationCredentials(password));
 | 
					      device.setAuthenticationCredentials(new AuthenticationCredentials(password));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,6 +90,13 @@ public class AccountsManager {
 | 
				
			||||||
    else                 return Optional.absent();
 | 
					    else                 return Optional.absent();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public boolean isRelayListed(String number) {
 | 
				
			||||||
 | 
					    byte[]                  token   = Util.getContactToken(number);
 | 
				
			||||||
 | 
					    Optional<ClientContact> contact = directory.get(token);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return contact.isPresent() && !Util.isEmpty(contact.get().getRelay());
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private void updateDirectory(Account account) {
 | 
					  private void updateDirectory(Account account) {
 | 
				
			||||||
    if (account.isActive()) {
 | 
					    if (account.isActive()) {
 | 
				
			||||||
      byte[]        token         = Util.getContactToken(account.getNumber());
 | 
					      byte[]        token         = Util.getContactToken(account.getNumber());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue