You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.6 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Estsh.Core.Model.Result;
using Estsh.Core.Models;
using Estsh.Core.Util;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace Estsh.Core.Controllers
{
public class WmsBaseController : Controller
{
public SysEmp CurrentEmp;
public override void OnActionExecuting(ActionExecutingContext context)
{
var controllerActionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;
//匿名访问不需要token认证、签名和登录
var allowanyone = controllerActionDescriptor.MethodInfo.GetCustomAttribute(typeof(AllowAnonymousAttribute), true);
if (allowanyone != null)
{
return;
}
WmsResponseResult result = new WmsResponseResult();
string? sessionUser = HttpContext.Session.GetString("PDAloginedUser");
if (!string.IsNullOrEmpty(sessionUser))
{
var user = JsonSerializer.Deserialize<SysEmp>(sessionUser);
CurrentEmp = user;
}
else
{
result.Code = 90001;
result.Msg = "用户登录超时,请重新登录";
context.Result = Json(result);
return;
}
}
}
}