查询角色
This commit is contained in:
parent
7cb1b09dc3
commit
6cf319996f
@ -9,6 +9,7 @@ using System.Drawing;
|
|||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using static asg_form.Controllers.login;
|
using static asg_form.Controllers.login;
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
|
||||||
namespace asg_form.Controllers
|
namespace asg_form.Controllers
|
||||||
{
|
{
|
||||||
@ -384,6 +385,46 @@ namespace asg_form.Controllers
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Route("api/v1/admin/rolealluser")]
|
||||||
|
[HttpGet]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<ActionResult<object>> RoleuserAsync(string rolename)
|
||||||
|
{
|
||||||
|
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
||||||
|
{
|
||||||
|
|
||||||
|
List<post_user> data = new List<post_user>();
|
||||||
|
var users= await userManager.GetUsersInRoleAsync(rolename);
|
||||||
|
foreach (var user1 in users)
|
||||||
|
{
|
||||||
|
post_user post_User = new post_user();
|
||||||
|
post_User.id = user1.Id;
|
||||||
|
post_User.name = user1.UserName;
|
||||||
|
post_User.email = user1.Email;
|
||||||
|
post_User.officium = user1.officium;
|
||||||
|
post_User.chinaname = user1.chinaname;
|
||||||
|
|
||||||
|
post_User.Base64 = user1.UserBase64;
|
||||||
|
post_User.Roles = (List<string>?)await userManager.GetRolesAsync(user1);
|
||||||
|
data.Add(post_User);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BadRequest(new error_mb { code = 400, message = "无管理员" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Route("api/v1/admin/excel/all")]
|
[Route("api/v1/admin/excel/all")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
|
@ -534,7 +534,11 @@ namespace asg_form.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user.Integral == null)
|
||||||
|
{
|
||||||
|
user.Integral = 0;
|
||||||
|
await userManager.UpdateAsync(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var claims = new List<Claim>();
|
var claims = new List<Claim>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user