111
This commit is contained in:
25
Service/Application.Web/Common/ComHelper.cs
Normal file
25
Service/Application.Web/Common/ComHelper.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace Application.Web;
|
||||
|
||||
public class ComHelper
|
||||
{
|
||||
public static string GetClientUserIp(HttpContext context)
|
||||
{
|
||||
var ip = context.Request.Headers["X-Forwarded-For"].FirstOrDefault();
|
||||
if (string.IsNullOrEmpty(ip))
|
||||
{
|
||||
ip = context.Connection.RemoteIpAddress.ToString();
|
||||
ip = ip.Replace("::ffff:", "");
|
||||
}
|
||||
if (ip.Contains(","))
|
||||
{
|
||||
ip = ip.Split(',')[0];
|
||||
}
|
||||
//var ip = context.Request.Cookies["kxUserIp"];
|
||||
//if (string.IsNullOrEmpty(ip))
|
||||
//{
|
||||
// ip = "0.0.0.0";
|
||||
//}
|
||||
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
@@ -18,12 +18,20 @@
|
||||
return token.Claims["userId"];
|
||||
}
|
||||
}
|
||||
public static string sid
|
||||
public static string accId
|
||||
{
|
||||
get
|
||||
{
|
||||
var token = App.HttpContext.GetTokenInfo();
|
||||
return token.Claims["token"];
|
||||
return token.Claims["accId"];
|
||||
}
|
||||
}
|
||||
public static int areaId
|
||||
{
|
||||
get
|
||||
{
|
||||
var token = App.HttpContext.GetTokenInfo();
|
||||
return Convert.ToInt32(token.Claims["areaId"]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user