2020-12-16 21:41:14 +01:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using StudyLib.API.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace StudyLib.API.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/[controller]")]
|
2020-12-20 18:53:24 +01:00
|
|
|
|
[Authorize]
|
2020-12-16 21:41:14 +01:00
|
|
|
|
[ApiController]
|
|
|
|
|
public class UserProfilesController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private UserManager<User> _userManager;
|
|
|
|
|
|
|
|
|
|
public UserProfilesController(UserManager<User> userManager)
|
|
|
|
|
{
|
|
|
|
|
_userManager = userManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Authorize]
|
|
|
|
|
public async Task<User> GetUserProfile()
|
|
|
|
|
{
|
|
|
|
|
string userId = User.Claims.First(c => c.Type == "UserID").Value;
|
|
|
|
|
var user = await _userManager.FindByIdAsync(userId);
|
|
|
|
|
return user;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|