Skip to content

Commit

Permalink
[fix]修正token读取错误问题
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jul 31, 2024
1 parent 5509189 commit d194d86
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions NewLife.CubeNC/Membership/ManagerProviderHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,15 @@ public static IManageUser LoadCookie(this IManageProvider provider, Boolean auto
var key = $"token-{SysConfig.Current.Name}";
var req = context?.Request;
var token = req?.Cookies[key];
var ts = token?.Split(".") ?? [];

// 尝试从url中获取token
if (ts.Length != 3) token = req?.Query["token"];
if (ts.Length != 3) token = req?.Query["jwtToken"];
if (token.IsNullOrEmpty() || token.Split(".").Length != 3) token = req?.Query["token"];
if (token.IsNullOrEmpty() || token.Split(".").Length != 3) token = req?.Query["jwtToken"];

// 尝试从头部获取token
if (ts.Length != 3) token = req?.Headers[HeaderNames.Authorization];
if (token.IsNullOrEmpty() || token.Split(".").Length != 3) token = req?.Headers[HeaderNames.Authorization];

if (ts.Length != 3) return null;
if (token.IsNullOrEmpty() || token.Split(".").Length != 3) return null;

token = token.Replace("Bearer ", "", StringComparison.OrdinalIgnoreCase);
span?.AppendTag(token);
Expand Down

0 comments on commit d194d86

Please sign in to comment.