Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么在webman中间件里判断登录过期 #5

Open
asyncpjax opened this issue Aug 31, 2022 · 3 comments
Open

怎么在webman中间件里判断登录过期 #5

asyncpjax opened this issue Aug 31, 2022 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@asyncpjax
Copy link

目前过期是抛出异常,没有具体的错误码啥的,怎么判断,难道try catch吗

@Tinywan
Copy link
Owner

Tinywan commented Sep 1, 2022

1、你可以使用 https://www.workerman.net/plugin/16 这个插件
2、你可以自己实现框架的异常类捕获过期异常类,自定义自己具体的错误码啥的

@Tinywan Tinywan added the help wanted Extra attention is needed label Oct 30, 2022
@lqllife
Copy link

lqllife commented Mar 1, 2023

try {
    JwtToken::getCurrentId();
} catch (JwtTokenException|JwtTokenExpiredException) {
    throw new ApiException('身份验证失败,请重新登录', 401);
}

@Tinywan
Copy link
Owner

Tinywan commented Mar 2, 2023

是的, 你也可以这样子捕捉异常

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants