68 lines
1.8 KiB
C#
68 lines
1.8 KiB
C#
|
// <copyright file="UserApiController.cs" company="alveus.dev">
|
||
|
// Copyright (c) alveus.dev. All rights reserved. Licensed under the MIT License.
|
||
|
// </copyright>
|
||
|
|
||
|
using Astral.ApiServer.Models;
|
||
|
using Astral.Services.Interfaces;
|
||
|
using Microsoft.AspNetCore.Authorization;
|
||
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
||
|
namespace Astral.ApiServer.Controllers.V1;
|
||
|
|
||
|
/// <summary>
|
||
|
/// User api controller.
|
||
|
/// </summary>
|
||
|
[Route("api/v1/user")]
|
||
|
[Authorize]
|
||
|
public class UserApiController : BaseApiController
|
||
|
{
|
||
|
private readonly IIdentityProvider _identityProvider;
|
||
|
|
||
|
/// <summary>
|
||
|
/// Initializes a new instance of the <see cref="UserApiController"/> class.
|
||
|
/// </summary>
|
||
|
/// <param name="identityProvider">Instance of <see cref="IIdentityProvider"/>.</param>
|
||
|
public UserApiController(IIdentityProvider identityProvider)
|
||
|
{
|
||
|
_identityProvider = identityProvider;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Get the user's profile.
|
||
|
/// </summary>
|
||
|
[HttpGet("profile")]
|
||
|
public IActionResult GetUserProfile()
|
||
|
{
|
||
|
var userId = _identityProvider.GetUserId();
|
||
|
var userName = _identityProvider.GetUserName();
|
||
|
|
||
|
return new JsonResult(new UserProfileResultModel()
|
||
|
{
|
||
|
Success = true,
|
||
|
AccountId = userId,
|
||
|
Username = userName,
|
||
|
XmppPassword = string.Empty,
|
||
|
DiscourseApiKey = string.Empty
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Does nothing for now since I believe the locker feature is deprecated.
|
||
|
/// </summary>
|
||
|
[HttpPost("locker")]
|
||
|
public IActionResult PostLocker()
|
||
|
{
|
||
|
return SuccessResult();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Does nothing for now since I believe the locker feature is deprecated.
|
||
|
/// </summary>
|
||
|
[HttpGet("locker")]
|
||
|
public IActionResult GetLocker()
|
||
|
{
|
||
|
return SuccessResult();
|
||
|
}
|
||
|
|
||
|
}
|