| | |
| | | package com.xcong.excoin.common.system.service; |
| | | |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import cn.hutool.crypto.asymmetric.Sign; |
| | | import cn.hutool.crypto.asymmetric.SignAlgorithm; |
| | | import com.xcong.excoin.common.exception.GlobalException; |
| | | import com.xcong.excoin.common.system.bean.LoginUserBean; |
| | | import com.xcong.excoin.modules.member.dao.MemberDao; |
| | | import com.xcong.excoin.modules.member.entity.MemberEntity; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.security.core.GrantedAuthority; |
| | |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | @Service("userDetailsService") |
| | | public class UserDetailsServiceImpl implements UserDetailsService { |
| | | |
| | | @Resource |
| | | private MemberDao memberDao; |
| | | |
| | | @Override |
| | | public LoginUserBean loadUserByUsername(String username) throws UsernameNotFoundException { |
| | | log.info("#登陆账号:{}#", username); |
| | | List<GrantedAuthority> grantedAuthorities = new ArrayList<>(); |
| | | // GrantedAuthority grantedAuthority = new SimpleGrantedAuthority("ROLE_ADMIN"); |
| | | // grantedAuthorities.add(grantedAuthority); |
| | | |
| | | MemberEntity memberEntity = new MemberEntity(); |
| | | memberEntity.setId(1L); |
| | | memberEntity.setUsername("11111"); |
| | | memberEntity.setPassword(new BCryptPasswordEncoder().encode("123456")); |
| | | MemberEntity memberEntity = memberDao.selectMemberInfoByAccount(username); |
| | | if (memberEntity != null) { |
| | | memberEntity.setPassword(new BCryptPasswordEncoder().encode(memberEntity.getPassword())); |
| | | } else { |
| | | throw new UsernameNotFoundException(""); |
| | | } |
| | | |
| | | if (MemberEntity.ACCOUNT_STATUS_DISABLED == memberEntity.getAccountStatus()) { |
| | | throw new GlobalException("账号已被禁用"); |
| | | } |
| | | |
| | | return new LoginUserBean(memberEntity, null, null); |
| | | } |