-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from netcorepal/v23
升级2.3.0,添加命令锁、JwtProvider示例
- Loading branch information
Showing
8 changed files
with
76 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<VersionPrefix>2.2.1</VersionPrefix> | ||
<VersionPrefix>2.3.0</VersionPrefix> | ||
<VersionSuffix></VersionSuffix> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
template/src/ABC.Template.Web/Controllers/UserController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Security.Claims; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using NetCorePal.Extensions.Dto; | ||
using NetCorePal.Extensions.Jwt; | ||
|
||
namespace ABC.Template.Web.Controllers; | ||
|
||
[Route("user")] | ||
public class UserController | ||
{ | ||
[Route("login")] | ||
[HttpPost] | ||
public async Task<ResponseData<string>> Login(string username, string password, | ||
[FromServices] IJwtProvider jwtProvider) | ||
{ | ||
var jwt = await jwtProvider.GenerateJwtToken( | ||
new JwtData("netcorepal", "netcorepal", | ||
[new Claim("name", username)], | ||
DateTime.Now, DateTime.Now.AddDays(1))); | ||
return jwt.AsResponseData(); | ||
} | ||
|
||
[Route("auth")] | ||
[HttpGet] | ||
[Authorize(AuthenticationSchemes = "Bearer")] | ||
public Task<ResponseData<bool>> Auth() | ||
{ | ||
return Task.FromResult(true.AsResponseData()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters