You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
50 lines
1.1 KiB
|
4 years ago
|
using Microsoft.AspNet.Identity;
|
||
|
|
using Microsoft.AspNet.Identity.EntityFramework;
|
||
|
|
using Microsoft.AspNet.Identity.Owin;
|
||
|
|
using Microsoft.Owin.Security;
|
||
|
|
using Owin;
|
||
|
|
using SpaAspNetCore.Models;
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Security.Claims;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using System.Web;
|
||
|
|
using System.Web.Http;
|
||
|
|
|
||
|
|
namespace SpaAspNetCore.Controllers
|
||
|
|
{
|
||
|
|
[Authorize]
|
||
|
|
public class MeController : ApiController
|
||
|
|
{
|
||
|
|
private ApplicationUserManager _userManager;
|
||
|
|
|
||
|
|
public MeController()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
public MeController(ApplicationUserManager userManager)
|
||
|
|
{
|
||
|
|
UserManager = userManager;
|
||
|
|
}
|
||
|
|
|
||
|
|
public ApplicationUserManager UserManager
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
return _userManager ?? HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();
|
||
|
|
}
|
||
|
|
private set
|
||
|
|
{
|
||
|
|
_userManager = value;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// GET api/Me
|
||
|
|
public GetViewModel Get()
|
||
|
|
{
|
||
|
|
var user = UserManager.FindById(User.Identity.GetUserId());
|
||
|
|
return new GetViewModel() { Hometown = user.Hometown };
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|