重构增加模型枚举值定义
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"log/slog"
|
||||
client2 "platform/web/domains/client"
|
||||
q "platform/web/queries"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -38,7 +39,7 @@ func Protect(c *fiber.Ctx, types []PayloadType, permissions []string) (*Context,
|
||||
}
|
||||
|
||||
case "Basic":
|
||||
if !slices.Contains(types, PayloadClientConfidential) {
|
||||
if !slices.Contains(types, PayloadSecuredServer) {
|
||||
slog.Debug("禁止使用 Basic 认证方式")
|
||||
return nil, fiber.NewError(fiber.StatusUnauthorized, "无效的令牌")
|
||||
}
|
||||
@@ -106,7 +107,7 @@ func authBasic(_ context.Context, token string) (*Context, error) {
|
||||
client, err := q.Client.
|
||||
Where(
|
||||
q.Client.ClientID.Eq(clientID),
|
||||
q.Client.Spec.Eq(3),
|
||||
q.Client.Spec.In(int32(client2.SpecWeb), int32(client2.SpecTrusted)),
|
||||
q.Client.GrantClient.Is(true),
|
||||
q.Client.Status.Eq(1)).
|
||||
Take()
|
||||
@@ -126,7 +127,7 @@ func authBasic(_ context.Context, token string) (*Context, error) {
|
||||
return &Context{
|
||||
Payload: Payload{
|
||||
Id: client.ID,
|
||||
Type: PayloadClientConfidential,
|
||||
Type: PayloadSecuredServer,
|
||||
Name: client.Name,
|
||||
Avatar: client.Icon,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user