Commit bfc7d6f2 authored by 黄奎's avatar 黄奎

新增匿名属性

parent d4c3c25a
......@@ -87,44 +87,52 @@ namespace Mall.CacheManager.User
/// <returns></returns>
public static UserInfo GetUserLoginInfo(object TenantId)
{
string cacheKey = UserModuleCacheKeyConfig.Mall_Login_Info + TenantId.ToString();
UserInfo userInfo = null;
try
{
userInfo = redis.StringGet<UserInfo>(cacheKey);
}
catch (Exception ex)
if (TenantId != null)
{
LogHelper.Write(ex, "GetUserLoginInfo");
}
if (userInfo == null)
{
Int32.TryParse(TenantId.ToString(), out int NewTenantId);
if (NewTenantId > 0)
string cacheKey = UserModuleCacheKeyConfig.Mall_Login_Info + TenantId.ToString();
try
{
string token = "";
var extModel = tenantRepository.GetEntity<RB_Tenant_Extend>(NewTenantId);
if (extModel != null)
userInfo = redis.StringGet<UserInfo>(cacheKey);
}
catch (Exception ex)
{
LogHelper.Write(ex, "GetUserLoginInfo");
}
if (userInfo == null)
{
Int32.TryParse(TenantId.ToString(), out int NewTenantId);
if (NewTenantId > 0)
{
UserInfo obj = new UserInfo
string token = "";
var extModel = tenantRepository.GetEntity<RB_Tenant_Extend>(NewTenantId);
if (extModel != null)
{
TenantId = extModel.TenantId,
Account = extModel.Account,
Name = extModel.Name,
MobilePhone = extModel.MobilePhone,
WeChatNum = extModel.WeChatNum,
IsEffective = extModel.IsEffective,
AccountValidate = extModel.AccountValidate,
CreateMiniPrograme = extModel.CreateMiniPrograme,
//MallName = extModel.MallName,
AccountStatus = extModel.AccountStatus,
Token = token,
SecretKey = "",
};
UserInfoSet(UserModuleCacheKeyConfig.Mall_Login_Info + TenantId, obj, Config.JwtExpirTime);
UserInfo obj = new UserInfo
{
TenantId = extModel.TenantId,
Account = extModel.Account,
Name = extModel.Name,
MobilePhone = extModel.MobilePhone,
WeChatNum = extModel.WeChatNum,
IsEffective = extModel.IsEffective,
AccountValidate = extModel.AccountValidate,
CreateMiniPrograme = extModel.CreateMiniPrograme,
//MallName = extModel.MallName,
AccountStatus = extModel.AccountStatus,
Token = token,
SecretKey = "",
};
UserInfoSet(UserModuleCacheKeyConfig.Mall_Login_Info + TenantId, obj, Config.JwtExpirTime);
}
}
}
}
else
{
userInfo = new UserInfo();
}
return userInfo;
}
......
......@@ -116,8 +116,8 @@ namespace Mall.WebApi.Controllers.MallBase
homePage = new
{
id = selfHomePage.Id,
title = selfHomePage.PageName,
id = miniProgram.MallBaseId,
title = miniProgram.MallName,
show_navs = selfHomePage.IsShowNav,
is_home_page = selfHomePage.IsHome,
navs = list
......@@ -300,7 +300,10 @@ namespace Mall.WebApi.Controllers.MallBase
}
}
}
return ApiResult.Success(data: homePage);
var objResult = new {
home_pages = homePage
};
return ApiResult.Success(data: objResult);
}
/// <summary>
......
......@@ -20,6 +20,7 @@ using Mall.Common.Plugin;
using Mall.Common.Enum.MallBase;
using Mall.Model.Entity.User;
using Mall.Module.Product;
using Microsoft.AspNetCore.Authorization;
namespace Mall.WebApi.Controllers.User
{
......@@ -27,7 +28,6 @@ namespace Mall.WebApi.Controllers.User
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class TenantController : BaseController
{
/// <summary>
......@@ -77,6 +77,7 @@ namespace Mall.WebApi.Controllers.User
#region 商户信息
[AllowAnonymous]
/// <summary>
/// 用户登录
/// </summary>
......@@ -152,6 +153,7 @@ namespace Mall.WebApi.Controllers.User
/// 用户注册第一步
/// </summary>
/// <returns></returns>
[AllowAnonymous]
public ApiResult SetTenantFirst()
{
var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString());
......@@ -171,6 +173,7 @@ namespace Mall.WebApi.Controllers.User
/// 用户注册第二步
/// </summary>
/// <returns></returns>
[AllowAnonymous]
public ApiResult SetTenantSecond()
{
var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString());
......@@ -194,6 +197,7 @@ namespace Mall.WebApi.Controllers.User
/// 修改密码账号
/// </summary>
/// <returns></returns>
[AllowAnonymous]
public ApiResult UpdateTenantPwd()
{
var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString());
......
......@@ -14,6 +14,7 @@ using Mall.Common.Enum.User;
using Mall.CacheManager.User;
using Newtonsoft.Json.Linq;
using Mall.Common;
using Microsoft.AspNetCore.Authorization;
namespace Mall.WebApi.Controllers.User
{
......
......@@ -17,6 +17,10 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;
using Mall.CacheManager.User;
using System.Linq;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http.Features;
namespace Mall.WebApi.Filter
{
......@@ -39,23 +43,15 @@ namespace Mall.WebApi.Filter
#region api监控日志
parm = DoApiMonitorLog(actionContext, ref token);
#endregion
//不需要验证TOKEN的CMD
List<string> notValidatList = new List<string>()
{
"/api/Tenant/Login",//用户登录
"/api/Tenant/SetTenantFirst",//用户注册第一步
"/api/Tenant/SetTenantSecond",//用户注册第二步
"/api/Tenant/UpdateTenantPwd",//忘记密码
"/api/Mall/GetHome",//
};
bool isCheckToken = true;
foreach (var item in notValidatList)
var endpoint = actionContext.HttpContext.Features.Get<IEndpointFeature>()?.Endpoint;
if (endpoint != null && endpoint.Metadata.GetMetadata<AllowAnonymousAttribute>() != null)
{
if (item== parm["cmd"].ToString())
{
isCheckToken = false;
}
isCheckToken = false;
}
#region Token校验
if (isCheckToken)
......
......@@ -5,6 +5,7 @@ using System.Text.Encodings.Web;
using System.Text.Unicode;
using System.Threading.Tasks;
using Mall.ThirdCore.Message;
using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
......@@ -34,7 +35,8 @@ namespace Mall.WebApi
.Configure<IISServerOptions>(x => x.AllowSynchronousIO = true);
services.AddControllers();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); //注入http上下文
services.AddMvc().AddJsonOptions(options =>
{
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
......@@ -66,6 +68,7 @@ namespace Mall.WebApi
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment