End User License consent system added

This commit is contained in:
2022-02-12 00:50:51 +00:00
parent 95f5d0dd53
commit b75d46324f
8 changed files with 81 additions and 16 deletions

View File

@@ -71,6 +71,12 @@ namespace AyaNova.Api.Controllers
//NOTE: lockout or other login impacting state is processed later in ReturnUserCredsOnSuccessfulAuthentication() because many of those states need to have exceptions once the user is known
//or return alternate result of auth etc
if (Core.License.LicenseConsentRequired)
{
await Task.Delay(AyaNova.Util.ServerBootConfig.FAILED_AUTH_DELAY);
return StatusCode(401, new ApiErrorResponse(ApiErrorCode.AUTHENTICATION_FAILED, "generalerror", "License agreement consent required"));
}
if (string.IsNullOrWhiteSpace(creds.Login) || string.IsNullOrWhiteSpace(creds.Password))
{
//Make a failed pw wait

View File

@@ -274,8 +274,31 @@ namespace AyaNova.Api.Controllers
}
/// <summary>
///
/// </summary>
/// <param name="acceptCode"></param>
/// <returns>HTTP 204 No Content result code on success or fail code with explanation</returns>
[AllowAnonymous]
[HttpPost("lc")]
[ApiExplorerSettings(IgnoreApi = true)]
public async Task<IActionResult> lc([FromBody] string acceptCode)
{
//END USER LICENSE AGREEMENT ROUTE ONLY CALLED FROM WEBAPP AND HIDDEN FROM VIEW AS A ROUTE
//SuperUser only and must have accept code
if (string.IsNullOrWhiteSpace(acceptCode) || acceptCode.ToLowerInvariant() != "iaccepttheagreement")
return StatusCode(403, new ApiNotAuthorizedResponse());
await Core.License.FlagEULA(ct, log);
//Log
await EventLogProcessor.LogEventToDatabaseAsync(new Event(1, 0, AyaType.Global, AyaEvent.Modified, "End user license agreement consent obtained"), ct);
return NoContent();
}
//------------------------------------------------------

View File

@@ -54,9 +54,10 @@ namespace AyaNova.Api.Controllers
var logo = await ct.Logo.AsNoTracking().SingleOrDefaultAsync();
if (logo == null)
{
return Ok(ApiOkResponse.Response(new { eval = showSampleLogins, ll = false, ml = false, sl = false }));
return Ok(ApiOkResponse.Response(new { eval = showSampleLogins, ll = false, ml = false, sl = false, lcr = AyaNova.Core.License.LicenseConsentRequired }));
}
return Ok(ApiOkResponse.Response(new { eval = showSampleLogins, ll = logo.Large != null ? true : false, ml = logo.Medium != null ? true : false, sl = logo.Small != null ? true : false }));
return Ok(ApiOkResponse.Response(
new { eval = showSampleLogins, ll = logo.Large != null ? true : false, ml = logo.Medium != null ? true : false, sl = logo.Small != null ? true : false, lcr = AyaNova.Core.License.LicenseConsentRequired }));
}
@@ -69,7 +70,7 @@ namespace AyaNova.Api.Controllers
public async Task<IActionResult> GetNewCount()
{
var UserId = UserIdFromContext.Id(HttpContext.Items);
if (serverState.IsClosed && UserId!=1)//bypass for superuser to fix fundamental problems
if (serverState.IsClosed && UserId != 1)//bypass for superuser to fix fundamental problems
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
return Ok(ApiOkResponse.Response(await ct.InAppNotification.CountAsync(z => z.UserId == UserId && z.Fetched == false)));