| | |
| | | } |
| | | |
| | | @Transactional |
| | | public void authenticate(String authorization) { |
| | | public Long authenticate(String authorization) { |
| | | String token = bearer(authorization); |
| | | if (token.isBlank()) throw new BusinessException(ErrorCode.UNAUTHORIZED, "请先登录管理后台"); |
| | | List<Map<String, Object>> rows = rows(""" |
| | | select s.id session_id, o.status |
| | | select s.id session_id, s.operator_id, o.status |
| | | from admin_session s join admin_operator o on o.id = s.operator_id |
| | | where s.access_token_hash = ? and s.revoked_at is null and s.access_expires_at > now() |
| | | and o.deleted = 0 |
| | |
| | | throw new BusinessException(ErrorCode.FORBIDDEN, "当前管理员账号已停用"); |
| | | } |
| | | jdbc.update("update admin_session set last_used_at = now() where id = ?", number(rows.get(0).get("sessionId"))); |
| | | return number(rows.get(0).get("operatorId")); |
| | | } |
| | | |
| | | private Map<String, Object> issueSession(Map<String, Object> operator) { |