Skip to content

Commit

Permalink
Move some controllers around
Browse files Browse the repository at this point in the history
  • Loading branch information
CorruptComputer committed Nov 9, 2024
1 parent 7db5d5d commit eb4b257
Show file tree
Hide file tree
Showing 11 changed files with 464 additions and 420 deletions.
67 changes: 67 additions & 0 deletions Backend/Bones.Api/Controllers/AccountController.cs
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 Backend/Bones.Api/Controllers/AccountManagementController.cs

This file was deleted.

Loading

0 comments on commit eb4b257

Please sign in to comment.