Changeset 057037b for backend/Helpers


Ignore:
Timestamp:
04/11/22 15:29:19 (3 years ago)
Author:
Danilo <danilo.najkov@…>
Branches:
master
Children:
7a983b0
Parents:
b66b3ac
Message:

backend full

Location:
backend/Helpers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • backend/Helpers/AuthorizeAttribute.cs

    rb66b3ac r057037b  
    1010    public void OnAuthorization(AuthorizationFilterContext context)
    1111    {
    12         var user = (User)context.HttpContext.Items["User"];
     12        var user = context.HttpContext.Items["User"];
    1313        if (user == null)
    1414        {
  • backend/Helpers/JwtMiddleware.cs

    rb66b3ac r057037b  
    44using Microsoft.IdentityModel.Tokens;
    55using System.IdentityModel.Tokens.Jwt;
    6 using System.Text;
    76using backend.Services;
    87using backend.Helpers;
     
    3433        {
    3534            var tokenHandler = new JwtSecurityTokenHandler();
    36             var key = Encoding.ASCII.GetBytes(_appSettings.Secret);
     35            var key = System.Text.Encoding.ASCII.GetBytes(_appSettings.Secret);
    3736            tokenHandler.ValidateToken(token, new TokenValidationParameters
    3837            {
     
    4746            var userId = int.Parse(jwtToken.Claims.First(x => x.Type == "id").Value);
    4847
    49             context.Items["User"] = userService.GetById(userId);
     48            context.Items["User"] = userId;
    5049        }
    5150        catch
Note: See TracChangeset for help on using the changeset viewer.