| | |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.HttpStatus; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.exception.user.StudyLoginException; |
| | | import com.ruoyi.common.core.utils.JwtUtils; |
| | |
| | | // 单设备登录校验:账号已在其他设备登录时,将先登录的设备强制下线 |
| | | // 注意:此处不能放在 try 中,否则会被 catch(Exception) 吞掉异常 |
| | | if (user != null && !Boolean.TRUE.equals(user.getIsCanLogin())) { |
| | | throw new StudyLoginException("当前登录账号在其他设备登录!", 505); |
| | | // 家长端被挤下线统一返回 401,便于前端统一跳转登录页 |
| | | throw new StudyLoginException("当前登录账号在其他设备登录!", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | | return user; |