mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-11-08 02:14:44 +08:00
v1.2版,全面实现SSO登陆
This commit is contained in:
38
OpenAuth.WebApi/Areas/SSO/Controllers/CheckController.cs
Normal file
38
OpenAuth.WebApi/Areas/SSO/Controllers/CheckController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Web.Http;
|
||||
using System.Web.Mvc;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.WebApi.Areas.SSO.Models.Services;
|
||||
|
||||
namespace OpenAuth.WebApi.Areas.SSO.Controllers
|
||||
{
|
||||
public class CheckController : Controller
|
||||
{
|
||||
private LoginApp _app;
|
||||
public CheckController()
|
||||
{
|
||||
_app = AutofacExt.GetFromFac<LoginApp>();
|
||||
}
|
||||
|
||||
public bool GetStatus(string token = "", string requestid = "")
|
||||
{
|
||||
if (new UserAuthSessionService().GetCache(token))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public string GetUser(string token = "", string requestid = "")
|
||||
{
|
||||
var user = new UserAuthSessionService().Get(token);
|
||||
if (user != null)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.GetLoginUser(user.UserName));
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Web.Http;
|
||||
using OpenAuth.WebApi.Areas.SSO.Models.Services;
|
||||
|
||||
namespace OpenAuth.WebApi.Areas.SSO.Controllers
|
||||
{
|
||||
public class PassportController : ApiController
|
||||
{
|
||||
public bool Get(string token = "", string requestid = "")
|
||||
{
|
||||
if (new UserAuthSessionService().GetCache(token))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
@using OpenAuth.WebApi.Areas.SSO.Models
|
||||
@model OpenAuth.WebApi.Areas.SSO.Models.PassportLoginRequest
|
||||
@model PassportLoginRequest
|
||||
@{
|
||||
ViewBag.Title = "用户授权应用登录";
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="App_Start\WebApiConfig.cs" />
|
||||
<Compile Include="Areas\SSO\Controllers\LoginController.cs" />
|
||||
<Compile Include="Areas\SSO\Controllers\PassportController.cs" />
|
||||
<Compile Include="Areas\SSO\Controllers\CheckController.cs" />
|
||||
<Compile Include="Areas\SSO\Models\AppInfo.cs" />
|
||||
<Compile Include="Areas\SSO\Models\AppUser.cs" />
|
||||
<Compile Include="Areas\SSO\Models\PassportLoginRequest.cs" />
|
||||
@@ -159,7 +159,6 @@
|
||||
<Compile Include="Areas\SSO\Models\Services\AppUserService.cs" />
|
||||
<Compile Include="Areas\SSO\Models\Services\UserAuthSessionService.cs" />
|
||||
<Compile Include="Areas\SSO\Models\StringExtensions.cs" />
|
||||
<Compile Include="Areas\SSO\Models\UserAuthSession.cs" />
|
||||
<Compile Include="Areas\SSO\SSOAreaRegistration.cs" />
|
||||
<Compile Include="AutofacExt.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
|
||||
Reference in New Issue
Block a user