add ability to get user based on username or email address
This commit is contained in:
@ -61,13 +61,15 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
// GET api/<controller>/name/x?siteid=x
|
||||
[HttpGet("name/{name}")]
|
||||
public User Get(string name, string siteid)
|
||||
// GET api/<controller>/name/{name}/{email}?siteid=x
|
||||
[HttpGet("name/{name}/{email}")]
|
||||
public User Get(string name, string email, string siteid)
|
||||
{
|
||||
if (int.TryParse(siteid, out int SiteId) && SiteId == _tenantManager.GetAlias().SiteId)
|
||||
{
|
||||
User user = _userManager.GetUser(name, SiteId);
|
||||
name = (name == "-") ? "" : name;
|
||||
email = (email == "-") ? "" : email;
|
||||
User user = _userManager.GetUser(name, email, SiteId);
|
||||
if (user == null)
|
||||
{
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
@ -76,7 +78,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized User Get Attempt {Username} {SiteId}", name, siteid);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized User Get Attempt {Username} {Email} {SiteId}", name, email, siteid);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user