update depenincy, add login and logout support

This commit is contained in:
2020-06-28 06:28:51 +08:00
parent d54b71badb
commit 3cbd8b7559
3 changed files with 28 additions and 12 deletions
+17 -5
View File
@@ -23,20 +23,23 @@ namespace YYApi.Helpers
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public string Set(int id, string type = "user")
public string Login(int id, string type = "user", string token = null)
{
return Set(id, new[] { type });
return Login(id, new[] { type }, token);
}
/// <summary>
/// 产生一个TOken并记录用户ID角色[多角色]
/// 产生一个Token并记录用户ID角色[多角色]
/// </summary>
/// <param name="id"></param>
/// <param name="type"></param>
/// <returns></returns>
public string Set(int id, string[] type)
public string Login(int id, string[] type, string uuid = null)
{
var uuid = Guid.NewGuid().ToString();
if (uuid == null)
{
uuid = Guid.NewGuid().ToString();
}
var loginItem = new YYLoginItem
{
Id = id,
@@ -46,5 +49,14 @@ namespace YYApi.Helpers
return uuid;
}
/// <summary>
/// 退出登陆
/// </summary>
/// <param name="uuid">登陆标识</param>
public void Logout(string uuid)
{
Cache.Remove(uuid);
}
}
}
+4
View File
@@ -62,3 +62,7 @@ app.UseYYAuth();
#Startup.cs
app.UseYYException();
```
### TODO:
1. 增加HANGFIRE 支持redis和sqlite 存储, 支持 基于其他系统的TOKEN认证和独立账号密码认证
+6 -6
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<OutputType>Library</OutputType>
<PackOnBuild>true</PackOnBuild>
<Version>0.2.3</Version>
@@ -23,12 +23,12 @@
<Folder Include="Exceptions\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.1.0" />
<PackageReference Include="HangFire.Core" Version="1.7.9" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.9" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.5.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.5.1" />
<PackageReference Include="HangFire.Core" Version="1.7.11" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.11" />
<PackageReference Include="Hangfire.Console" Version="1.4.2" />
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.8.1" />
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.8.4" />
</ItemGroup>
<ProjectExtensions>
<MonoDevelop>