mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
紧急修复因SSO功能造成的某些页面访问失败
This commit is contained in:
parent
5bfba2aee4
commit
860af2a0f9
@ -16,6 +16,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.SSO;
|
||||
using OpenAuth.App.ViewModel;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
@ -41,11 +42,11 @@ namespace OpenAuth.App
|
||||
|
||||
public IEnumerable<ModuleElement> LoadByModuleId(int id)
|
||||
{
|
||||
string username = HttpContext.Current.User.Identity.Name;
|
||||
string username = AuthUtil.GetUserName();
|
||||
return _moduleEleManService.LoadByModuleId(username, id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 获取带有授权状态的菜单列表
|
||||
/// </summary>
|
||||
/// <param name="accessType">授权类型,当前有RoleElement/UserElement</param>
|
||||
@ -56,7 +57,7 @@ namespace OpenAuth.App
|
||||
/// <param name="moduleId">模块ID</param>
|
||||
public List<dynamic> LoadWithAccess(string accessType, int firstId, int moduleId)
|
||||
{
|
||||
string username = HttpContext.Current.User.Identity.Name;
|
||||
string username = AuthUtil.GetUserName();
|
||||
return _moduleEleManService.LoadWithAccess(username, accessType, firstId, moduleId);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace OpenAuth.App
|
||||
/// </summary>
|
||||
public dynamic Load(int parentId, int pageindex, int pagesize)
|
||||
{
|
||||
return _moduleManService.Load(AuthUtil.GetCurrentUser().User.Account, parentId, pageindex, pagesize);
|
||||
return _moduleManService.Load(AuthUtil.GetUserName(), parentId, pageindex, pagesize);
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
|
@ -90,6 +90,28 @@ namespace OpenAuth.App.SSO
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前登录的用户名
|
||||
/// <para>通过URL中的Token参数或Cookie中的Token</para>
|
||||
/// </summary>
|
||||
/// <param name="remark">The remark.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string GetUserName(string remark = "")
|
||||
{
|
||||
var requestUri = String.Format("/SSO/Check/GetUserName?token={0}&requestid={1}", GetToken(), remark);
|
||||
|
||||
try
|
||||
{
|
||||
var value = _helper.Get(null, requestUri);
|
||||
return value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 되쩍쌈왯
|
||||
/// </summary>
|
||||
|
@ -4,6 +4,7 @@ using OpenAuth.Domain;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using OpenAuth.App.SSO;
|
||||
using OpenAuth.Mvc.Models;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
@ -46,7 +47,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// </summary>
|
||||
public string Load(int categoryId, int pageCurrent = 1, int pageSize = 30)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.Load(User.Identity.Name, categoryId, pageCurrent, pageSize));
|
||||
return JsonHelper.Instance.Serialize(_app.Load(AuthUtil.GetUserName(), categoryId, pageCurrent, pageSize));
|
||||
}
|
||||
|
||||
public string LoadForTree()
|
||||
@ -94,7 +95,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// <returns>System.String.</returns>
|
||||
public string LoadWithAccess(int cId, int firstId, string key)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.LoadWithAccess(User.Identity.Name,key,firstId, cId));
|
||||
return JsonHelper.Instance.Serialize(_app.LoadWithAccess(AuthUtil.GetUserName(),key,firstId, cId));
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using OpenAuth.App;
|
||||
using OpenAuth.Domain;
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using OpenAuth.App.SSO;
|
||||
using OpenAuth.Mvc.Models;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
@ -51,7 +52,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// </summary>
|
||||
public string Load(int parentId, int pageCurrent = 1, int pageSize = 30)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.Load(User.Identity.Name, parentId, pageCurrent, pageSize));
|
||||
return JsonHelper.Instance.Serialize(_app.Load(AuthUtil.GetUserName(), parentId, pageCurrent, pageSize));
|
||||
}
|
||||
|
||||
public string Delete(int Id)
|
||||
|
@ -40,11 +40,22 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
|
||||
}
|
||||
|
||||
public string GetUser(string token = "", string requestid = "")
|
||||
{
|
||||
string userName = GetUserName(token, requestid);
|
||||
if (!string.IsNullOrEmpty(userName))
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.GetLoginUser(userName));
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string GetUserName(string token, string requestid = "")
|
||||
{
|
||||
var user = new UserAuthSessionService().Get(token);
|
||||
if (user != null)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.GetLoginUser(user.UserName));
|
||||
return user.UserName;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
|
Loading…
Reference in New Issue
Block a user