Commit af0ea11e authored by 黄奎's avatar 黄奎

新增单点验证

parent 21b42026
......@@ -1556,5 +1556,19 @@ namespace REBORN.Common
return surveyURL;
}
}
/// <summary>
/// 是否开启单点登陆
/// </summary>
public static bool IsSSO
{
get {
bool isSSO = false;
string IsSSOStr = ConfigurationManager.AppSettings["IsSSO"] ?? "";
Int32.TryParse(IsSSOStr,out int result);
isSSO = (result == 1);
return isSSO;
}
}
}
}
\ No newline at end of file
......@@ -542,4 +542,6 @@
<add key="MailConfig" value='[{"MailFromAccount":"service@viitto.com","MailPassword":"bSL7FkkFCBsU3omk","Title":"Travel Design产品团队","RB_Group_id":"2"}]'/>
<!--画途邮箱基础信息结束-->
<add key='SurveyH5URL' value='file:///E:/work/surprised/html/ImpressionOpinionSurvey/guestlogin.html'/>
<!--是否开启单点登陆-->
<add key="IsSSO" value="0"></add>
</appSettings>
\ No newline at end of file
using REBORN.Common;
using REBORN.Common.API;
using REBORN.Common.Plugin;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using Newtonsoft.Json;
using System.Threading;
using REBORN.CacheKey;
using REBORN.Common;
using REBORN.Common.API;
using REBORN.Common.Enum;
using System.Globalization;
using System.Threading.Tasks;
using REBORN.Common.AOP;
using REBORN.Common.Plugin;
using REBORN.Common.Plugin.Redis;
using System.Web.Razor.Tokenizer;
using REBORN.CacheKey;
namespace REBORN.WebApi.Controllers
{
......@@ -53,11 +51,7 @@ namespace REBORN.WebApi.Controllers
{
request.groupId = tokenUserInfo.groupId;//教育端 集团id使用 token解析获取
}
////领队陈博账户出现异常,加此代码验证是否是本人使用
//if ((request.requestFrom == ApiRequestFromEnum.ERP || request.requestFrom == ApiRequestFromEnum.App || request.requestFrom == ApiRequestFromEnum.PPTist) && request.uid == "2800")
//{
// return new ApiResult() { resultCode = (int)ResultCode.TokenIllegal, message = "token 不合法,请重新登录", data = null };
//}
}
//获取客户端版本信息
if (!string.IsNullOrEmpty(request.version) && request.version.Contains("42Assistant"))
......@@ -96,73 +90,15 @@ namespace REBORN.WebApi.Controllers
#region 策略验证
if (meth != null && !model.AllowAnonymous)
{
// PPT User策略检查
//if (meth.GetCustomAttribute(typeof(PPTTokenPolicyAttribute), false) != null)
//{
// string key = string.Concat(CacheKey.UserModuleCacheKeyConfig.PPT_USER_LOGIN_INFO, request.uid);
// var user = _redisHelper.StringGet<UserInfo>(key);
// #region 2024-06-26 add by:W 开始 判断集团的logo信息是否有改动,有则更新用户信息缓存数据
// var cacheKey = CacheKey.UserModuleCacheKeyConfig.PPT_Group_LOGO_INFO + (user?.RB_Group_id ?? 0);
// if (_redisHelper.KeyExists(cacheKey))
// {
// string groupLogoStr = _redisHelper.Get(cacheKey);
// if (!string.IsNullOrWhiteSpace(groupLogoStr))
// {
// var groupLogo = _redisHelper.StringGet<UserInfo>(cacheKey);
// if (groupLogo != null && user != null)
// {
// user.IsUpdate = true;
// user.IsEnableLogo = groupLogo.IsEnableLogo;
// user.GroupLogoList = groupLogo.GroupLogoList;
// }
// }
// }
// #endregion
// if (user == null)
// {
// return new ApiResult() { resultCode = (int)ResultCode.TokenOverdue, message = "当前登录信息已失效,请重新登录", data = null };
// }
// else if (tokenUserInfo == null || tokenUserInfo.requestFrom != ApiRequestFromEnum.PPTist)
// {
// return new ApiResult() { resultCode = (int)ResultCode.TokenIllegal, message = "token 不合法,请重新登录", data = null };
// }
// else if (user.token != request.token && user.IPAddress != request.ip)
// {
// //if (Common.Config.IsOnline)
// //{
// // return new ApiResult() { resultCode = (int)ResultCode.AccountRemoteLogin, message = "你的账号已经在别处登录,请退出后重新登录", data = null };
// //}
// }
// else if (user.IsUpdate)
// {
// attach = new
// {
// userinfo = new
// {
// id = Common.DES.Encrypt(user.EmployeeId.ToString()),
// nickname = user.emName,
// photo = Config.GetFileUrl(user.Icon),
// company = user.GroupName,
// logo = user.GroupPic,
// isTemplate = user.EmployeeId == 615 ? 1 : 0,
// ia = user.IsAdmin,
// it = user.RB_Group_id != 101,
// iv = user.PPTUserType == 1,
// ic = user.IsGroupCreate,
// expire = user.Expire,
// gid = Common.DES.Encrypt((user?.RB_Group_id ?? 0).ToString()),
// isp = (user?.RB_Group_id ?? 0) == 2,//是否是和平
// user.IsEnableLogo,
// user.GroupLogoList,
// }
// };
// user.IsUpdate = false;
// _redisHelper.StringSet<UserInfo>(UserModuleCacheKeyConfig.PPT_USER_LOGIN_INFO + user.EmployeeId, user, Config.JwtExpirTime);
// }
//}
if (Common.Config.IsSSO)
{
string key = string.Concat(CacheKey.UserModuleCacheKeyConfig.USER_Login_Info, request.uid);
var user = _redisHelper.StringGet<UserInfo>(key);
if (user != null && user.token != request.token && user.IPAddress != request.ip)
{
return new ApiResult() { resultCode = (int)ResultCode.AccountRemoteLogin, message = "您的账号已经在别处登录,请退出后重新登录", data = null };
}
}
}
#endregion
......@@ -202,9 +138,6 @@ namespace REBORN.WebApi.Controllers
if (request.languageId == 1)
{
//string RobjStr = JsonConvert.SerializeObject(robj);
//string Rstr = Microsoft.VisualBasic.Strings.StrConv(RobjStr, Microsoft.VisualBasic.VbStrConv.TraditionalChinese, 0);
//return JsonConvert.DeserializeObject<ApiResult>(Rstr);
return robj;
}
else
......
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