|
|
@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.user.security.auth.credential; |
|
|
|
|
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.pmapi.user.constant.LoginTypeEnum; |
|
|
|
import com.ningdatech.pmapi.user.security.auth.validate.CommonLoginException; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.http.HttpMethod; |
|
|
|
import org.springframework.security.authentication.AuthenticationServiceException; |
|
|
@@ -53,7 +54,6 @@ public class CredentialAuthFilter extends AbstractAuthenticationProcessingFilter |
|
|
|
} |
|
|
|
paramValid(identifier, credential, loginType); |
|
|
|
|
|
|
|
|
|
|
|
identifier = trim(identifier); |
|
|
|
credential = trim(credential); |
|
|
|
loginType = trim(loginType); |
|
|
@@ -62,6 +62,10 @@ public class CredentialAuthFilter extends AbstractAuthenticationProcessingFilter |
|
|
|
// Allow subclasses to set the "details" property |
|
|
|
setDetails(request, authRequest); |
|
|
|
return this.getAuthenticationManager().authenticate(authRequest); |
|
|
|
} catch (CommonLoginException e) { |
|
|
|
throw new CommonLoginException(e.getMessage()); |
|
|
|
} catch (BadCredentialsException e) { |
|
|
|
throw new BadCredentialsException(e.getMessage()); |
|
|
|
} catch (AuthenticationException e) { |
|
|
|
throw new BadCredentialsException("账号或密码错误"); |
|
|
|
} catch (BizException e) { |
|
|
@@ -80,19 +84,19 @@ public class CredentialAuthFilter extends AbstractAuthenticationProcessingFilter |
|
|
|
switch (loginTypeEnum) { |
|
|
|
case DING_QR_LOGIN: { |
|
|
|
if (StringUtils.isBlank(credential)) { |
|
|
|
throw new BadCredentialsException("浙政钉扫码登陆 授权码 不能为空 credential"); |
|
|
|
throw new CommonLoginException("浙政钉扫码登陆 授权码 不能为空 credential"); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
case USERNAME_PASSWORD_LOGIN: { |
|
|
|
if (StringUtils.isBlank(identifier) || StringUtils.isBlank(credential)) { |
|
|
|
throw new BadCredentialsException("账号密码登陆 账号密码不能为空 identifier credential"); |
|
|
|
throw new CommonLoginException("账号密码登陆 账号密码不能为空 identifier credential"); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
case PHONE_VERIFICATION_CODE_LOGIN: { |
|
|
|
if (StringUtils.isBlank(identifier) || StringUtils.isBlank(credential)) { |
|
|
|
throw new BadCredentialsException("手机号验证码登陆 手机号或验证码不能为空 identifier credential"); |
|
|
|
throw new CommonLoginException("手机号验证码登陆 手机号或验证码不能为空 identifier credential"); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|