This commit is contained in:
2020-11-19 00:55:47 +00:00
parent f21e66de08
commit a255aab73c
6 changed files with 88 additions and 88 deletions

View File

@@ -111,65 +111,6 @@ namespace AyaNova.Api.Controllers
}
// /// <summary>
// /// Put (update) User
// /// (Login and / or Password are not changed if set to null / omitted)
// /// </summary>
// /// <param name="id"></param>
// /// <param name="inObj"></param>
// /// <returns></returns>
// [HttpPut("{id}")]
// public async Task<IActionResult> PutUser([FromRoute] long id, [FromBody] User inObj)
// {
// if (!serverState.IsOpen)
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
// if (!ModelState.IsValid)
// {
// return BadRequest(new ApiErrorResponse(ModelState));
// }
// var o = await ct.User.SingleOrDefaultAsync(z => z.Id == id);
// if (o == null)
// {
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
// }
// //Instantiate the business object handler
// UserBiz biz = UserBiz.GetBiz(ct, HttpContext);
// if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
// {
// return StatusCode(403, new ApiNotAuthorizedResponse());
// }
// try
// {
// if (!await biz.PutAsync(o, inObj))
// return BadRequest(new ApiErrorResponse(biz.Errors));
// }
// catch (DbUpdateConcurrencyException)
// {
// if (!UserExists(id))
// {
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
// }
// else
// {
// //exists but was changed by another user
// //I considered returning new and old record, but where would it end?
// //Better to let the client decide what to do than to send extra data that is not required
// return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
// }
// }
// return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency }));
// }
/// <summary>
/// Create User
/// </summary>
@@ -376,16 +317,16 @@ namespace AyaNova.Api.Controllers
return Ok(ApiOkResponse.Response(u.UserType != UserType.Customer && u.UserType != UserType.HeadOffice));
}
/// <summary>
/// Generate new random credentials for User
/// and email them to the user
/// <summary>
/// Generate time limited password reset code for User
/// and email to them
///
/// </summary>
/// <param name="id">User id</param>
/// <param name="apiVersion">From route path</param>
/// <returns>NoContent</returns>
[HttpPost("generate-creds-email/{id}")]
public async Task<IActionResult> GenerateCredsAndEmailUser([FromRoute] long id, ApiVersion apiVersion)
[HttpPost("send-reset-code/{id}")]
public async Task<IActionResult> SendPasswordResetCode([FromRoute] long id, ApiVersion apiVersion)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
@@ -394,7 +335,7 @@ namespace AyaNova.Api.Controllers
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
bool successfulOperation=await biz.GenerateCredsAndEmailUser(id);
bool successfulOperation = await biz.SendPasswordResetCode(id);
if (successfulOperation == false)
return BadRequest(new ApiErrorResponse(biz.Errors));
else