13693261870
2024-08-23 9e1c97a6fbb4451f32a85ebbf00f6a64156fccc0
se-auth/src/main/java/com/se/auth/controller/TokenController.java
@@ -6,10 +6,7 @@
import com.se.auth.form.RegisterBody;
import com.se.auth.service.SysLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.se.common.core.domain.R;
import com.se.common.core.utils.JwtUtils;
import com.se.common.core.utils.StringUtils;
@@ -41,6 +38,23 @@
        return R.ok(tokenService.createToken(userInfo));
    }
    @GetMapping("validate")
    @PostMapping("validate")
    public R<Object> validate(HttpServletRequest request) {
        try {
            boolean flag = false;
            String token = SecurityUtils.getToken(request);
            if (!StringUtils.isNotEmpty(token)) {
                String userName = JwtUtils.getUserName(token);
                flag = !StringUtils.isEmpty(userName);
            }
            return R.ok(flag);
        } catch (Exception ex) {
            return R.fail(ex.getMessage());
        }
    }
    @DeleteMapping("logout")
    public R<?> logout(HttpServletRequest request)
    {