|
@@ -29,32 +29,33 @@ public class UserServiceImpl implements UserDetailsService {
|
|
|
private EduTenantMapper eduTenantMapper;
|
|
|
@Autowired
|
|
|
private RedisTemplate redisTemplate;
|
|
|
- @Autowired
|
|
|
- private SysRoleService sysRoleService;
|
|
|
@Override
|
|
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
|
|
if (StringUtils.isBlank(username)) {
|
|
|
throw new UsernameNotFoundException("username is empty");
|
|
|
}
|
|
|
+ HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
|
|
|
EduTenant tenant = eduTenantMapper.selectOne(new LambdaQueryWrapper<EduTenant>().eq(EduTenant::getTenantPhone, username));
|
|
|
if (tenant == null) {
|
|
|
throw new UsernameNotFoundException("username not found");
|
|
|
}
|
|
|
- HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
|
|
|
- String code = request.getParameter("password");
|
|
|
- if (StringUtils.isBlank(code)) {
|
|
|
- throw new UsernameNotFoundException("验证码为空");
|
|
|
+ if ("admin".equals(request.getParameter("loginFrom"))) {
|
|
|
+ return new User(tenant.getTenantPhone(),null,new ArrayList<>());
|
|
|
+ }else {
|
|
|
+ String code = request.getParameter("password");
|
|
|
+ if (StringUtils.isBlank(code)) {
|
|
|
+ throw new UsernameNotFoundException("验证码为空");
|
|
|
+ }
|
|
|
+ Object object = "1234";//redisTemplate.opsForValue().get("code_" + username);
|
|
|
+ if (object == null) {
|
|
|
+ throw new UsernameNotFoundException("验证码为空");
|
|
|
+ }
|
|
|
+ if (code.equals(object.toString())){
|
|
|
+ redisTemplate.opsForValue().set(username+"_info", JSON.toJSONString(tenant));
|
|
|
+ return new User(tenant.getTenantPhone(),code, new ArrayList<>());
|
|
|
+ }
|
|
|
+ throw new UsernameNotFoundException("验证码错误");
|
|
|
}
|
|
|
- Object object = "1234";//redisTemplate.opsForValue().get("code_" + username);
|
|
|
- if (object == null) {
|
|
|
- throw new UsernameNotFoundException("验证码为空");
|
|
|
- }
|
|
|
- if (code.equals(object.toString())){
|
|
|
- redisTemplate.opsForValue().set(username+"_info", JSON.toJSONString(tenant));
|
|
|
|
|
|
- List<SysRole> list = sysRoleService.getRoleListByUserId(tenant.getId());
|
|
|
- return new User(tenant.getTenantPhone(),code,list);
|
|
|
- }
|
|
|
- throw new UsernameNotFoundException("验证码错误");
|
|
|
}
|
|
|
}
|