|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package com.ruoyi.framework.web.service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.utils.RsaUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
|
|
|
import org.springframework.security.authentication.BadCredentialsException;
|
|
|
|
@ -63,15 +65,21 @@ public class SysLoginService
|
|
|
|
|
*/
|
|
|
|
|
public String login(String username, String password, String code, String uuid)
|
|
|
|
|
{
|
|
|
|
|
String strP;
|
|
|
|
|
try {
|
|
|
|
|
strP = RsaUtils.decryptByPrivateKey(password);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
// 验证码校验
|
|
|
|
|
validateCaptcha(username, code, uuid);
|
|
|
|
|
// 登录前置校验
|
|
|
|
|
loginPreCheck(username, password);
|
|
|
|
|
loginPreCheck(username, strP);
|
|
|
|
|
// 用户验证
|
|
|
|
|
Authentication authentication = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
|
|
|
|
|
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, strP);
|
|
|
|
|
AuthenticationContextHolder.setContext(authenticationToken);
|
|
|
|
|
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
|
|
|
|
authentication = authenticationManager.authenticate(authenticationToken);
|
|
|
|
|