Spaces:
No application file
No application file
Download Tawasol.API/Endpoints/UserEndpoints.cs from MahmoudSaeedYousef/spaceM: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/MahmoudSaeedYousef/spaceM/resolve/main/Tawasol.API/Endpoints/UserEndpoints.cs
- Command line
-
hf download hf://spaces/MahmoudSaeedYousef/spaceM/Tawasol.API/Endpoints/UserEndpoints.cs
-
curl -L -o UserEndpoints.cs https://huggingface.co/spaces/MahmoudSaeedYousef/spaceM/resolve/main/Tawasol.API/Endpoints/UserEndpoints.cs
1.22 kB
| using System.Security.Claims; | |
| using MediatR; | |
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.AspNetCore.Mvc; | |
| using Tawasol.Application.Features.Users.Commands.UpdateDeviceToken; | |
| using Tawasol.Application.Features.Users.Queries.GetUserProfile; | |
| namespace Tawasol.API.Endpoints; | |
| public static class UserEndpoints | |
| { | |
| public static void MapUserEndpoints(this IEndpointRouteBuilder app) | |
| { | |
| var group = app.MapGroup("/api/users"); | |
| group.MapGet("/profile", [Authorize] async (ClaimsPrincipal user, ISender mediator) => | |
| { | |
| var userId = Guid.Parse(user.FindFirstValue(ClaimTypes.NameIdentifier)!); | |
| var result = await mediator.Send(new GetUserProfileQuery(userId)); | |
| return Results.Ok(result); | |
| }) | |
| .WithName("GetUserProfile"); | |
| group.MapPatch("/device-token", [Authorize] async ([FromBody] string token, ClaimsPrincipal user, ISender mediator) => | |
| { | |
| var userId = Guid.Parse(user.FindFirstValue(ClaimTypes.NameIdentifier)!); | |
| var result = await mediator.Send(new UpdateDeviceTokenCommand(userId, token)); | |
| return Results.Ok(result); | |
| }) | |
| .WithName("UpdateDeviceToken"); | |
| } | |
| } | |