moved service to separate project (Kontur developer said "WTF WHY ARE U STORING SERVICES IN INFRASTRUCTURE SLAVA D")
This commit is contained in:
parent
147fb683f7
commit
41ff1555f8
11 changed files with 33 additions and 9 deletions
|
|
@ -1,31 +0,0 @@
|
|||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using SurveyBackend.Core.Models;
|
||||
|
||||
namespace SurveyBackend.Infrastructure.Helpers;
|
||||
|
||||
public class TokenHelper
|
||||
{
|
||||
public static string GetAuthToken(User user)
|
||||
{
|
||||
var userId = user.Id.ToString();
|
||||
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new(ClaimTypes.NameIdentifier, userId)
|
||||
};
|
||||
|
||||
var jwt = new JwtSecurityToken(
|
||||
claims: claims,
|
||||
issuer: AuthOptions.Issuer,
|
||||
audience: AuthOptions.Audience,
|
||||
expires: DateTime.UtcNow + AuthOptions.TokenLifetime,
|
||||
signingCredentials: new SigningCredentials(AuthOptions.SymmetricSecurityKey, SecurityAlgorithms.HmacSha256)
|
||||
);
|
||||
|
||||
var token = new JwtSecurityTokenHandler().WriteToken(jwt);
|
||||
|
||||
return token;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue