| | |
| | | package com.sinata.framework.web.service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.stereotype.Component; |
| | | import com.sinata.common.constant.CacheConstants; |
| | | import com.sinata.common.constant.Constants; |
| | | import com.sinata.common.constant.UserConstants; |
| | |
| | | import com.sinata.framework.security.context.AuthenticationContextHolder; |
| | | import com.sinata.system.service.ISysConfigService; |
| | | import com.sinata.system.service.ISysUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * 登录校验方法 |
| | |
| | | @Component |
| | | public class SysLoginService |
| | | { |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Resource |
| | | private AuthenticationManager authenticationManager; |
| | |
| | | * @param uuid 唯一标识 |
| | | * @return 结果 |
| | | */ |
| | | public String login(String username, String password, String code, String uuid) |
| | | public LoginUser login(String username, String password, String code, String uuid) |
| | | { |
| | | // 验证码校验 |
| | | validateCaptcha(username, code, uuid); |
| | |
| | | LoginUser loginUser = (LoginUser) authentication.getPrincipal(); |
| | | recordLoginInfo(loginUser.getUserId()); |
| | | // 生成token |
| | | return tokenService.createToken(loginUser); |
| | | return loginUser; |
| | | } |
| | | |
| | | /** |