// ***********************************************************************
// Assembly : OpenAuth.WebApi
// Author : yubaolee
// Created : 07-11-2016
//
// Last Modified By : yubaolee
// Last Modified On : 07-11-2016
// Contact :
// File: CheckController.cs
// ***********************************************************************
using System.Web.Mvc;
using Infrastructure;
using OpenAuth.App;
using OpenAuth.App.SSO;
namespace OpenAuth.WebApi.Areas.SSO.Controllers
{
///
/// sso验证
/// 其他站点通过后台Post来认证
/// 或使用静态类OpenAuth.App.SSO.AuthUtil访问
///
public class CheckController : Controller
{
private AuthorizeApp _app;
public CheckController()
{
_app = AutofacExt.GetFromFac();
}
public bool GetStatus(string token = "", string requestid = "")
{
if (new UserAuthSessionService().GetCache(token))
{
return true;
}
return false;
}
public string GetUser(string token = "", string requestid = "")
{
string userName = GetUserName(token, requestid);
if (!string.IsNullOrEmpty(userName))
{
return JsonHelper.Instance.Serialize(_app.GetAccessedControls(userName));
}
return string.Empty;
}
public string GetUserName(string token, string requestid = "")
{
var user = new UserAuthSessionService().Get(token);
if (user != null)
{
return user.UserName;
}
return string.Empty;
}
[HttpPost]
public string Login(PassportLoginRequest request)
{
return JsonHelper.Instance.Serialize(SSOAuthUtil.Parse(request));
}
}
}