use of top.longmarch.lmcore.exception.BusinessException in project longmarch by yuyueqty.
the class UserLoginService method doLogin.
private TokenInfo doLogin(ShiroUsernamePasswordToken token, HttpServletRequest request) {
Subject subject = SecurityUtils.getSubject();
try {
subject.login(token);
Session session = subject.getSession(false);
session.setAttribute(Constant.USER_ID, UserUtil.getUserId());
session.setAttribute(Constant.USERNAME, UserUtil.getUsername());
this.onSuccess(request);
return new TokenInfo(session.getId().toString());
} catch (AccountException e) {
throw new BusinessException(11, e.getMessage());
} catch (AuthenticationException e1) {
if (LoginTypeEnum.PHONE.equals(token.getLoginType())) {
throw new BusinessException(12, "验证码不正确");
} else {
throw new BusinessException(11, "账号或密码不正确");
}
}
}
use of top.longmarch.lmcore.exception.BusinessException in project longmarch by yuyueqty.
the class ActiveUserServiceImpl method findPasswordByPhone.
@Override
public String findPasswordByPhone(String phone, String code) {
MsgUtil.checkVerificationCode(phone, code);
String newPassword = RandomUtil.randomString(6);
SysUser sysUser = sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhone, phone));
if (sysUser == null) {
throw new BusinessException(5000, "账号不存在");
}
if (StatusEnum.no(sysUser.getStatus())) {
throw new BusinessException(5000, "账号已被禁用,请联系管理员");
}
updateUserPassword(sysUser.getId(), newPassword);
messageResultInfoService.sendPhoneLoginPassword(newPassword, phone);
return newPassword;
}
Aggregations