优化SSO登录

This commit is contained in:
yubaolee
2016-12-27 11:25:51 +08:00
parent a3bdcf83ec
commit ccf1269eca
19 changed files with 108 additions and 240 deletions

View File

@@ -9,8 +9,10 @@
// File: CheckController.cs
// ***********************************************************************
using System;
using System.Web.Mvc;
using Infrastructure;
using Infrastructure.Cache;
using OpenAuth.App;
using OpenAuth.App.SSO;
@@ -24,6 +26,7 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
public class CheckController : Controller
{
private AuthorizeApp _app;
private ObjCacheProvider<UserAuthSession> _objCacheProvider = new ObjCacheProvider<UserAuthSession>();
public CheckController()
{
_app = AutofacExt.GetFromFac<AuthorizeApp>();
@@ -31,7 +34,7 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
public bool GetStatus(string token = "", string requestid = "")
{
if (new UserAuthSessionService().GetCache(token))
if (_objCacheProvider.GetCache(token) != null)
{
return true;
}
@@ -52,7 +55,7 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
public string GetUserName(string token, string requestid = "")
{
var user = new UserAuthSessionService().Get(token);
var user = _objCacheProvider.GetCache(token);
if (user != null)
{
return user.UserName;
@@ -66,5 +69,19 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
{
return JsonHelper.Instance.Serialize(SSOAuthUtil.Parse(request));
}
[HttpPost]
public bool Logout(string token, string requestid)
{
try
{
_objCacheProvider.Remove(token);
return true;
}
catch (Exception)
{
return false;
}
}
}
}