-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7db5d5d
commit eb4b257
Showing
11 changed files
with
464 additions
and
420 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using Bones.Database.DbSets.AccountManagement; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Bones.Api.Controllers; | ||
|
||
/// <summary> | ||
/// Handles everything related to User Accounts | ||
/// </summary> | ||
/// <param name="sender">MediatR sender</param> | ||
/// <remarks> | ||
/// Created using this as a reference: | ||
/// https://github.com/dotnet/aspnetcore/blob/main/src/Identity/Core/src/IdentityApiEndpointRouteBuilderExtensions.cs | ||
/// </remarks> | ||
public sealed class AccountController(ISender sender) : BonesControllerBase(sender) | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="Email"></param> | ||
/// <param name="DisplayName"></param> | ||
public record GetMyBasicInfoResponse(string Email, string DisplayName); | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <returns></returns> | ||
[HttpGet("my/basic-info", Name = "GetMyBasicInfoAsync")] | ||
[ProducesResponseType<GetMyBasicInfoResponse>(StatusCodes.Status200OK)] | ||
public async Task<ActionResult> GetMyBasicInfoAsync() | ||
{ | ||
BonesUser user = await GetCurrentBonesUserAsync(); | ||
|
||
return Ok(new GetMyBasicInfoResponse( | ||
user.Email ?? string.Empty, | ||
user.DisplayName ?? user.Email ?? string.Empty)); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="Email"></param> | ||
/// <param name="EmailConfirmed"></param> | ||
/// <param name="EmailConfirmedDateTime"></param> | ||
/// <param name="DisplayName"></param> | ||
/// <param name="CreateDateTime"></param> | ||
public record GetMyProfileResponse(string Email, bool EmailConfirmed, DateTimeOffset? EmailConfirmedDateTime, string DisplayName, DateTimeOffset CreateDateTime); | ||
|
||
/// <summary> | ||
/// Returns a users own full profile info | ||
/// </summary> | ||
/// <returns><see cref="GetMyProfileResponse"/></returns> | ||
[HttpGet("my/profile", Name = "GetMyProfileAsync")] | ||
[ProducesResponseType<GetMyProfileResponse>(StatusCodes.Status200OK)] | ||
public async Task<ActionResult> GetMyProfileAsync() | ||
{ | ||
BonesUser user = await GetCurrentBonesUserAsync(); | ||
|
||
|
||
return Ok(new GetMyProfileResponse( | ||
user.Email ?? string.Empty, | ||
user.EmailConfirmed, | ||
user.EmailConfirmedDateTime, | ||
user.DisplayName ?? user.Email ?? string.Empty, | ||
user.CreateDateTime | ||
)); | ||
} | ||
} |
229 changes: 0 additions & 229 deletions
229
Backend/Bones.Api/Controllers/AccountManagementController.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.