update README

This commit is contained in:
yubaolee
2016-07-08 19:08:47 +08:00
parent 781ae8900d
commit 6bd3a04a9d
4 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
using System;
namespace OpenAuth.WebApi.Areas.SSO.Models.Services
{
public class AppInfoService : ServiceContext
{
public AppInfo Get(string appKey)
{
//可以从数据库读取
return new AppInfo
{
AppKey = "670b14728ad9902aecba32e22fa4f6bd",
AppSecret = "670b14728ad9902aecba32e22fa4f6bd",
Icon = "/Content/img/default-app.png",
IsEnable = true,
Remark = "OpenAuth.net",
ReturnUrl = "http://localhost:53050",
Title = "OpenAuth.Net",
CreateTime = DateTime.Now,
};
}
}
}

View File

@@ -0,0 +1,16 @@
namespace OpenAuth.WebApi.Areas.SSO.Models.Services
{
public class AppUserService : ServiceContext
{
public AppUser Get(string username = "")
{
//模拟用户
return new AppUser
{
Nick = "超级管理员",
UserName = username,
UserPwd = "xxxxxxxxx"
};
}
}
}

View File

@@ -0,0 +1,51 @@
using System;
using Infrastructure.Cache;
namespace OpenAuth.WebApi.Areas.SSO.Models.Services
{
public class UserAuthSessionService : ServiceContext
{
public UserAuthSessionService()
{
SetCacheInstance(new SessionContext());
}
public bool Create(UserAuthSession model)
{
//设置缓存
return CacheContext.Set(model.Token, model);
}
public UserAuthSession Get(string token)
{
var sessionCacheItem = CacheContext.Get<UserAuthSession>(token);
return sessionCacheItem;
}
public bool GetCache(string token)
{
var cache = Get(token);
if (cache == null) return false;
if (cache.InvalidTime > DateTime.Now)
{
//延长
cache.InvalidTime = DateTime.Now.AddMinutes(5);
//设置缓存
CacheContext.Set(cache.Token, cache);
return true;
}
//移除无效Session缓存
Remove(token);
return false;
}
public void Remove(string token)
{
CacheContext.Remove(token);
}
}
}