as is
This commit is contained in:
@@ -41,13 +41,13 @@ public class ClaimsService : IClaimsService
|
||||
return claimsIdentity;
|
||||
}
|
||||
|
||||
public int GetCurrentUserId()
|
||||
public int? GetCurrentUserId()
|
||||
{
|
||||
var currUserId = _httpContextAccessor.HttpContext
|
||||
?.User.FindFirstValue(JwtRegisteredClaimNames.Sub);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(currUserId))
|
||||
throw new InvalidOperationException("在错误的位置获取当前登录用户");
|
||||
return null;
|
||||
|
||||
return Convert.ToInt32(currUserId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user