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

分组拦截, 登录接口不拦截中对退出登录接口没判断非空才拦截 #23

Closed
wyaow opened this issue Sep 18, 2021 · 3 comments

Comments

@wyaow
Copy link

wyaow commented Sep 18, 2021

测试用例报错
=== RUN TestGroupAuthPath
gtoken_test.go:41: Group auth path test
gtoken_test.go:67: error: /system/test auth path error
--- FAIL: TestGroupAuthPath (0.00s)
FAIL

@wyaow
Copy link
Author

wyaow commented Sep 18, 2021

原因是:没有对退出登录接口判断是否配置了。没配置就会有点小问题。
if m.MiddlewareType == MiddlewareTypeGroup {
if gstr.HasSuffix(urlPath, m.LoginPath) ||
gstr.HasSuffix(urlPath, m.LogoutPath) {
return false
}
}

应该改为
// 分组拦截,登录接口不拦截, 配置了退出登录接口不拦截
if m.MiddlewareType == MiddlewareTypeGroup {
if gstr.HasSuffix(urlPath, m.LoginPath) ||
(m.LogoutPath != "" && gstr.HasSuffix(urlPath, m.LogoutPath)) {
return false
}
}

@zcool321
Copy link
Collaborator

zcool321 commented Oct 2, 2021

代码初始化有对m.LogoutPath == ""进行校验,难道你的m.LogoutPath为空?

@zcool321
Copy link
Collaborator

已添加

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants