Changeset 057037b for backend/Helpers
- Timestamp:
- 04/11/22 15:29:19 (3 years ago)
- Branches:
- master
- Children:
- 7a983b0
- Parents:
- b66b3ac
- Location:
- backend/Helpers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
backend/Helpers/AuthorizeAttribute.cs
rb66b3ac r057037b 10 10 public void OnAuthorization(AuthorizationFilterContext context) 11 11 { 12 var user = (User)context.HttpContext.Items["User"];12 var user = context.HttpContext.Items["User"]; 13 13 if (user == null) 14 14 { -
backend/Helpers/JwtMiddleware.cs
rb66b3ac r057037b 4 4 using Microsoft.IdentityModel.Tokens; 5 5 using System.IdentityModel.Tokens.Jwt; 6 using System.Text;7 6 using backend.Services; 8 7 using backend.Helpers; … … 34 33 { 35 34 var tokenHandler = new JwtSecurityTokenHandler(); 36 var key = Encoding.ASCII.GetBytes(_appSettings.Secret);35 var key = System.Text.Encoding.ASCII.GetBytes(_appSettings.Secret); 37 36 tokenHandler.ValidateToken(token, new TokenValidationParameters 38 37 { … … 47 46 var userId = int.Parse(jwtToken.Claims.First(x => x.Type == "id").Value); 48 47 49 context.Items["User"] = user Service.GetById(userId);48 context.Items["User"] = userId; 50 49 } 51 50 catch
Note:
See TracChangeset
for help on using the changeset viewer.