优化注册服务

This commit is contained in:
不做码农
2023-03-18 07:58:39 +08:00
parent 1993299799
commit 5dc7545c12
8 changed files with 33 additions and 56 deletions

View File

@@ -1,7 +1,5 @@
using Infrastructure;
using Infrastructure.Extensions;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
@@ -10,7 +8,6 @@ using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UAParser;
using ZR.Model.System;
@@ -73,7 +70,10 @@ namespace ZR.Admin.WebApi.Extensions
public static long GetUId(this HttpContext context)
{
var uid = context.User.FindFirstValue(ClaimTypes.PrimarySid);
if (uid.IsEmpty() || uid.IsNullOrZero())
{
throw new CustomException(ResultCode.DENY, "未登录");
}
return !string.IsNullOrEmpty(uid) ? long.Parse(uid) : 0;
}