/** {@inheritDoc} */ @Override public boolean delete(String id) { boolean deleted = false; IUser user = userRepository.findById(id); if (user != null) { IContact contact = user.getContact(); if (contact != null && contact.getId() != null) { contactService.delete(contact.getId()); } userRepository.delete(user); deleted = true; } return deleted; }
/** {@inheritDoc} */ @Override public IUser getByNameAndPassword(String name, String password) { IUser user = null; if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(password)) { user = userRepository.findByNameAndPassword(name, password); } return user; }
@Override public IUser login(String name, String password) { IUser user = userRepository.findByNameAndPassword(name, password); if (user != null) { if (user.getContact() != null && user.getContact().getId() != null) { user.getContact().setOnline(true); IConnection connection = connectionService.createConnection(); user.getContact().setConnection(connection); contactService.update(user.getContact()); } } else { user = createInstance(); user.getContact().setOnline(false); } return user; }