use of org.codenergic.theskeleton.user.UserEntity in project theskeleton by codenergic.
the class SocialConnectionService method addConnection.
@Override
@Transactional
public void addConnection(Connection<?> connection) {
ConnectionData data = connection.createData();
int rank = connectionRepository.getRank(userId, data.getProviderId());
SocialConnectionEntity userConnection = new SocialConnectionEntity().setUser(new UserEntity().setId(userId)).setProvider(data.getProviderId()).setProviderUserId(data.getProviderUserId()).setRank(rank).setDisplayName(data.getDisplayName()).setProfileUrl(data.getProfileUrl()).setImageUrl(data.getImageUrl()).setAccessToken(encrypt(data.getAccessToken())).setSecret(encrypt(data.getSecret())).setRefreshToken(encrypt(data.getRefreshToken())).setExpireTime(data.getExpireTime());
connectionRepository.save(userConnection);
}
use of org.codenergic.theskeleton.user.UserEntity in project theskeleton by codenergic.
the class RoleServiceImpl method addRoleToUser.
@Override
@Transactional
public UserEntity addRoleToUser(String username, String roleCode) {
UserEntity user = userRepository.findByUsername(username).orElseThrow(() -> new UsernameNotFoundException(username));
RoleEntity role = roleRepository.findByCode(roleCode).orElseThrow(() -> new RoleNotFoundException(roleCode));
return userRoleRepository.save(new UserRoleEntity(user, role)).getUser();
}
use of org.codenergic.theskeleton.user.UserEntity in project theskeleton by codenergic.
the class RegistrationServiceImpl method activateUser.
@Override
@Transactional
public void activateUser(String activationToken) {
try {
TokenStoreRestData token = tokenStoreService.findAndVerifyToken(activationToken);
UserEntity user = (UserEntity) token.getUser();
if (user.isEnabled()) {
throw new RegistrationException("Your Account is already activated");
}
user.setEnabled(true);
} catch (InvalidSignatureException e) {
throw new RegistrationException("Invalid Activation Key");
}
}
Aggregations