Commit 536b9ba9 by shiwenbo

购砂单位用户、场站用户和司机用户增加校验是否停用逻辑

parent d25ae9df
......@@ -2,14 +2,17 @@ package com.beecode.inz.authentication.provider;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.DisabledException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.crypto.password.PasswordEncoder;
import com.beecode.inz.basis.pojo.DriverUser;
import com.beecode.inz.basis.service.DriverUserService;
......@@ -36,6 +39,8 @@ public class DriverUserAuthProvider implements AuthenticationProvider {
throw new BadCredentialsException("用户名或密码错误!");
}
checkUserState(driverUser);
String pwd = driverUser.getPassword();
if (!passwordEncoder.matches(passWord, pwd)) {
throw new BadCredentialsException("密码错误!");
......@@ -48,4 +53,13 @@ public class DriverUserAuthProvider implements AuthenticationProvider {
public boolean supports(Class<?> authentication) {
return authentication != null && authentication == UsernamePasswordAuthenticationToken.class;
}
private void checkUserState(DriverUser driverUser) {
if(null == driverUser)
return;
if (!driverUser.isEnabled()) {
throw new DisabledException("该用户被停用,无法登录业务,请联系系统管理员。");
}
}
}
......@@ -6,6 +6,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.DisabledException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
......@@ -38,6 +39,8 @@ public class SandUserAuthProvider implements AuthenticationProvider {
throw new BadCredentialsException("用户名或密码错误!");
}
checkUserState(sandUser);
String pwd = sandUser.getPassword();
if (!passwordEncoder.matches(passWord, pwd)) {
throw new BadCredentialsException("密码错误!");
......@@ -50,4 +53,13 @@ public class SandUserAuthProvider implements AuthenticationProvider {
public boolean supports(Class<?> authentication) {
return authentication != null && authentication == UsernamePasswordAuthenticationToken.class;
}
private void checkUserState(SandUser sandUser) {
if(null == sandUser)
return;
if (!sandUser.isEnabled()) {
throw new DisabledException("该用户被停用,无法登录业务,请联系系统管理员。");
}
}
}
......@@ -6,6 +6,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.DisabledException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
......@@ -38,6 +39,8 @@ public class WarehouseUserAuthenticationProvider implements AuthenticationProvi
throw new BadCredentialsException("用户名或密码错误!");
}
checkUserState(warehouseUser);
String pwd = warehouseUser.getPassword();
if (!passwordEncoder.matches(passWord, pwd)) {
throw new BadCredentialsException("用户名或密码错误!");
......@@ -50,4 +53,13 @@ public class WarehouseUserAuthenticationProvider implements AuthenticationProvi
public boolean supports(Class<?> authentication) {
return authentication != null && authentication == UsernamePasswordAuthenticationToken.class;
}
private void checkUserState(WarehouseUser warehouseUser) {
if(null == warehouseUser)
return;
if (!warehouseUser.isEnabled()) {
throw new DisabledException("该用户被停用,无法登录业务,请联系系统管理员。");
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment