generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #127 from amosproj/112-BE-user-management
feat: user management endpoints
- Loading branch information
Showing
5 changed files
with
228 additions
and
31 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
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,15 @@ | ||
using System.IdentityModel.Tokens.Jwt; | ||
using Microsoft.Net.Http.Headers; | ||
|
||
namespace Deskstar.Core; | ||
|
||
public class RequestInteractions | ||
{ | ||
public static Guid ExtractIdFromRequest(HttpRequest request) | ||
{ | ||
var accessToken = request.Headers[HeaderNames.Authorization].ToString().Replace("Bearer ", string.Empty); | ||
var handler = new JwtSecurityTokenHandler(); | ||
var jwtSecurityToken = handler.ReadJwtToken(accessToken); | ||
return new Guid(jwtSecurityToken.Claims.First(claim => claim.Type == JwtRegisteredClaimNames.NameId).Value); | ||
} | ||
} |
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
Oops, something went wrong.