|
|
|
@ -13,6 +13,7 @@ using System.Linq;
|
|
|
|
|
using System.Security.Claims;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace Platform.Apis
|
|
|
|
|
{
|
|
|
|
@ -120,6 +121,15 @@ namespace Platform.Apis
|
|
|
|
|
return Unauthorized(ModelState.AddModelError("已过期"));
|
|
|
|
|
}
|
|
|
|
|
var userName = token.Claims.FirstOrDefault(o => o.Type == this._parameters.NameClaimType).Value;
|
|
|
|
|
var user = this._userRepo.Table()
|
|
|
|
|
.Include(o => o.OrganUsers)
|
|
|
|
|
.ThenInclude(o => o.Organ)
|
|
|
|
|
.FirstOrDefault(o => o.UserName == userName);
|
|
|
|
|
var userMainOrgan = user.OrganUsers.OrderByDescending(o => o.IsDefault).ThenBy(o => o.OrganId).FirstOrDefault();
|
|
|
|
|
var claims = new List<Claim> {
|
|
|
|
|
new Claim(this._parameters.NameClaimType, userName),
|
|
|
|
|
new Claim("OrganId", userMainOrgan.OrganId.ToString())
|
|
|
|
|
};
|
|
|
|
|
return Ok(CreateToken(userName));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|