| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.project.system.mapper.SysUserMapper;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.authentication.AuthenticationManager;
|
| | | import org.springframework.security.authentication.BadCredentialsException;
|
| | |
| | | return loginUser.getUserId();
|
| | | }
|
| | |
|
| | | @Autowired
|
| | | private SysUserMapper sysUserMapper;
|
| | |
|
| | | /**
|
| | | * 登录验证
|
| | | *
|
| | |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
| | | LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
| | | recordLoginInfo(loginUser.getUserId());
|
| | | // 更新用户信息,修改当前选中公司
|
| | | SysUser user = loginUser.getUser();
|
| | | if(factoryId != null){
|
| | | user.setTenantId(factoryId);
|
| | | }else{
|
| | | user.setTenantId(tokenService.getDeptIdsByUserId(user.getUserId())[0]);
|
| | | }
|
| | | sysUserMapper.updateUser(user);
|
| | | // 生成token
|
| | | return tokenService.createToken(loginUser);
|
| | | }
|