更新
This commit is contained in:
1 parent
012f8edf8b
commit
36ff960fbd
33 files changed
+1644
-344
No files matched your search
@@ -24,6 +24,9 @@ const (
|
||||
EndPlatform End = "platform" // 平台端 /platform/**
|
||||
EndBackend End = "backend" // 租户(用户)端 /backend/**
|
||||
EndApp End = "app" // 移动端与小程序 /api/**
|
||||
// EndGuest 游客轻身份:小程序手机号授权签发的临时令牌(user_type=guest),
|
||||
// 仅免登录业务控制器显式放行,数据落在 yz_guest_data,转正后按手机号合并。
|
||||
EndGuest End = "guest"
|
||||
)
|
||||
|
||||
// 错误分类直接决定 HTTP 状态码,因此必须与前端拦截器行为对齐:
|
||||
@@ -93,6 +96,12 @@ func Claims(auth string, allowed ...End) (*jwtutil.Claims, error) {
|
||||
return claims, nil
|
||||
}
|
||||
|
||||
// IsGuest 判断解析结果是否为游客令牌(user_type=guest)。
|
||||
// 控制器据此分流:游客请求不进业务表,走 gueststore 通用存储。
|
||||
func IsGuest(claims *jwtutil.Claims) bool {
|
||||
return claims != nil && claims.UserType == string(EndGuest)
|
||||
}
|
||||
|
||||
// PathEnd 按路由前缀判定接口属于哪个端;前缀不属于任何端时 ok=false。
|
||||
func PathEnd(path string) (End, bool) {
|
||||
p := strings.ToLower(path)
|
||||
|
||||
Reference in new issue
Block a user