use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.
the class UacUserServiceImpl method activeUser.
@Override
public void activeUser(String activeUserToken) {
Preconditions.checkArgument(!StringUtils.isEmpty(activeUserToken), "激活用户失败");
String activeUserKey = RedisKeyUtil.getActiveUserKey(activeUserToken);
String email = redisService.getKey(activeUserKey);
if (StringUtils.isEmpty(email)) {
throw new UacBizException(ErrorCodeEnum.UAC10011030);
}
// 修改用户状态, 绑定访客角色
UacUser uacUser = new UacUser();
uacUser.setEmail(email);
uacUser = uacUserMapper.selectOne(uacUser);
if (uacUser == null) {
logger.error("找不到用户信息. email={}", email);
throw new UacBizException(ErrorCodeEnum.UAC10011004, email);
}
UacUser update = new UacUser();
update.setId(uacUser.getId());
update.setStatus(UacUserStatusEnum.ENABLE.getKey());
LoginAuthDto loginAuthDto = new LoginAuthDto();
loginAuthDto.setUserId(uacUser.getId());
loginAuthDto.setUserName(uacUser.getLoginName());
loginAuthDto.setLoginName(uacUser.getLoginName());
update.setUpdateInfo(loginAuthDto);
UacUser user = this.queryByUserId(uacUser.getId());
Map<String, Object> param = Maps.newHashMap();
param.put("loginName", user.getLoginName());
param.put("dateTime", DateUtil.formatDateTime(new Date()));
Set<String> to = Sets.newHashSet();
to.add(user.getEmail());
MqMessageData mqMessageData = emailProducer.sendEmailMq(to, UacEmailTemplateEnum.ACTIVE_USER_SUCCESS, AliyunMqTopicConstants.MqTagEnum.ACTIVE_USER_SUCCESS, param);
userManager.activeUser(mqMessageData, update, activeUserKey);
}
use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.
the class UacUserServiceImpl method validateEmailResetPwd.
private void validateEmailResetPwd(ForgetResetPasswordDto forgetResetPasswordDto) {
// 校验注册信息
String forgetToken = forgetResetPasswordDto.getForgetToken();
String loginPwd = forgetResetPasswordDto.getLoginPwd();
String loginName = forgetResetPasswordDto.getLoginName();
String email = forgetResetPasswordDto.getEmail();
String emailCode = forgetResetPasswordDto.getEmailCode();
Preconditions.checkArgument(!StringUtils.isEmpty(loginName), ErrorCodeEnum.UAC10011007.msg());
Preconditions.checkArgument(!StringUtils.isEmpty(email), ErrorCodeEnum.UAC10011018.msg());
Preconditions.checkArgument(!StringUtils.isEmpty(loginPwd), ErrorCodeEnum.UAC10011014.msg());
Preconditions.checkArgument(!StringUtils.isEmpty(forgetToken), "非法操作");
Preconditions.checkArgument(!StringUtils.isEmpty(emailCode), "验证码不能为空");
// 验证token
String key = RedisKeyUtil.getResetPwdTokenKey(email);
String forgetKey = redisService.getKey(key);
try {
HttpAesUtil.decrypt(forgetToken, forgetKey, false, forgetKey);
} catch (Exception e) {
throw new UacBizException(ErrorCodeEnum.UAC10011031);
}
int count = this.countUserByLoginNameAndEmail(loginName, email);
// 校验token
if (count < 1) {
throw new UacBizException(ErrorCodeEnum.UAC10011032, loginName, email);
}
}
use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.
the class UacUserServiceImpl method getUserBindRoleDto.
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public UserBindRoleVo getUserBindRoleDto(Long userId) {
UserBindRoleVo userBindRoleVo = new UserBindRoleVo();
Set<Long> alreadyBindRoleIdSet = Sets.newHashSet();
UacUser uacUser = this.queryByUserId(userId);
if (uacUser == null) {
logger.error("找不到userId={}, 的用户", userId);
throw new UacBizException(ErrorCodeEnum.UAC10011003, userId);
}
// 查询所有角色包括该用户拥有的角色
List<BindRoleDto> bindRoleDtoList = uacUserMapper.selectAllNeedBindRole(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);
// 该角色已经绑定的用户
List<UacRoleUser> setAlreadyBindRoleSet = uacRoleUserService.listByUserId(userId);
Set<BindRoleDto> allUserSet = new HashSet<>(bindRoleDtoList);
for (UacRoleUser uacRoleUser : setAlreadyBindRoleSet) {
alreadyBindRoleIdSet.add(uacRoleUser.getRoleId());
}
userBindRoleVo.setAllRoleSet(allUserSet);
userBindRoleVo.setAlreadyBindRoleIdSet(alreadyBindRoleIdSet);
return userBindRoleVo;
}
use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.
the class EmailProducer method sendEmailMq.
/**
* Send email mq.
*
* @param emailSet the email set
* @param emailTemplateEnum the email template enum
* @param param the param
*/
public MqMessageData sendEmailMq(Set<String> emailSet, UacEmailTemplateEnum emailTemplateEnum, AliyunMqTopicConstants.MqTagEnum tagEnum, Map<String, Object> param) {
log.info("pcSendEmailRequest - 发送邮件MQ. emailSet={}, param={}", emailSet, param);
String msgBody;
try {
Preconditions.checkArgument(emailTemplateEnum != null, "邮箱模板信息不存在");
PcSendEmailRequest request = new PcSendEmailRequest();
String templateLocation = emailTemplateEnum.getLocation();
String text = uacFreeMarkerService.getTemplate(param, templateLocation);
request.setText(text);
request.setTo(emailSet);
request.setSubject(emailTemplateEnum.getSubject());
msgBody = JSON.toJSONString(request);
} catch (Exception e) {
log.error("发送邮件验证码 smsMessage转换为json字符串失败", e);
throw new UacBizException(ErrorCodeEnum.UAC10011021);
}
String topic = tagEnum.getTopic();
String tag = tagEnum.getTag();
String key = RedisKeyUtil.createMqKey(topic, tag, emailSet.toString(), msgBody);
return new MqMessageData(msgBody, topic, tag, key);
}
use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.
the class UacLoginServiceImpl method loginAfter.
@Override
public LoginRespDto loginAfter(Long applicationId) {
LoginRespDto loginRespDto = new LoginRespDto();
String loginName = SecurityUtils.getCurrentLoginName();
if (StringUtils.isEmpty(loginName)) {
log.error("操作超时, 请重新登录 loginName={}", loginName);
Preconditions.checkArgument(StringUtils.isNotEmpty(loginName), "操作超时, 请重新登录");
}
UacUser uacUser = uacUserService.findByLoginName(loginName);
if (PublicUtil.isEmpty(uacUser)) {
log.info("找不到用户信息 loginName={}", loginName);
throw new UacBizException(ErrorCodeEnum.UAC10011002, loginName);
}
LoginAuthDto loginAuthDto = this.getLoginAuthDto(uacUser);
List<MenuVo> menuVoList = uacMenuService.getMenuVoList(uacUser.getId(), applicationId);
if (PublicUtil.isNotEmpty(menuVoList) && UacConstant.MENU_ROOT.equals(menuVoList.get(0).getMenuCode())) {
menuVoList = menuVoList.get(0).getSubMenu();
}
loginRespDto.setLoginAuthDto(loginAuthDto);
loginRespDto.setMenuList(menuVoList);
return loginRespDto;
}
Aggregations