59 lines
2.0 KiB
C#
59 lines
2.0 KiB
C#
using IdentityServer.Extensions;
|
|
using IdentityServer.Models;
|
|
using IdentityServer3.Core.Logging;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Security.Claims;
|
|
using System.Threading.Tasks;
|
|
using System.Web.Http;
|
|
|
|
namespace IdentityServer.Controllers
|
|
{
|
|
public class UserController : ApiController
|
|
{
|
|
private readonly static ILog Logger = LogProvider.GetCurrentClassLogger();
|
|
|
|
[Route("taloyhtio/token")]
|
|
[HttpPost]
|
|
//[Authorize]
|
|
public Task Token(TokenRequestModel model)
|
|
{
|
|
//if (model == null || !ModelState.IsValid)
|
|
//{
|
|
// return Task.FromResult(new HttpResponseMessage
|
|
// {
|
|
// Content = new StringContent("invalid request", Encoding.UTF8, "text/html"),
|
|
// StatusCode = HttpStatusCode.BadRequest
|
|
// });
|
|
//}
|
|
|
|
TaloyhtioUserService.AddUserAsync(new TaloyhtioUser
|
|
{
|
|
Username = model.Username,
|
|
Password = model.Username,
|
|
Subject = Guid.NewGuid().ToString(),
|
|
Claims = new List<Claim>
|
|
{
|
|
new Claim("username", model.Username),
|
|
new Claim("role", model.Role),
|
|
new Claim("userId", model.UserId.ToString()),
|
|
new Claim("pmcGuid", model.PmcGuid.ToString()),
|
|
new Claim("condoGuid", model.CondoGuid.ToString()),
|
|
new Claim("relativePath", model.RelativePath),
|
|
new Claim("isPropertyManager", model.IsPropertyManager.ToString()),
|
|
new Claim("isAdmin", model.IsAdmin.ToString())
|
|
}
|
|
});
|
|
|
|
//var html = "abcd";
|
|
//var content = new StringContent(html, Encoding.UTF8, "text/html");
|
|
//var response = new HttpResponseMessage
|
|
//{
|
|
// Content = content
|
|
//};
|
|
//return Task.FromResult(response);
|
|
|
|
return Task.FromResult(0);
|
|
}
|
|
}
|
|
} |