This commit is contained in:
xiangwb
2018-04-08 16:14:02 +08:00
parent 7f679837aa
commit 82b0e63166
@@ -8,6 +8,8 @@ import com.xwbing.service.sys.SysAuthorityService;
import com.xwbing.service.sys.SysRoleService;
import com.xwbing.service.sys.SysUserService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
@@ -90,11 +92,11 @@ public class MyShiroRealm extends AuthorizingRealm {
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) {
UsernamePasswordCaptchaToken captchaToken = (UsernamePasswordCaptchaToken) authenticationToken;
//1.校验验证码
// String captcha = captchaToken.getCaptcha();
// String imgCode = (String) SecurityUtils.getSubject().getSession().getAttribute(CommonConstant.KEY_CAPTCHA);
// if (StringUtils.isEmpty(captcha) || !captcha.equalsIgnoreCase(imgCode)) {
// throw new AuthenticationException("验证码错误");
// }
String captcha = captchaToken.getCaptcha();
String imgCode = (String) SecurityUtils.getSubject().getSession().getAttribute(CommonConstant.KEY_CAPTCHA);
if (StringUtils.isEmpty(captcha) || !captcha.equalsIgnoreCase(imgCode)) {
throw new AuthenticationException("验证码错误");
}
//2.查是否有此用户
SysUser user = sysUserService.getByUserName(captchaToken.getUsername());
if (user == null) {