This commit is contained in:
2022-12-29 21:48:21 +00:00
parent 29fbccf667
commit e51c7a2a8e
2 changed files with 102 additions and 0 deletions

View File

@@ -9,6 +9,8 @@ using System.Linq;
using Sockeye.Models;
using Sockeye.Api.ControllerHelpers;
using Sockeye.Biz;
using System.Text;
using System;
namespace Sockeye.Api.Controllers
@@ -129,12 +131,111 @@ namespace Sockeye.Api.Controllers
//v7 backdoor password generator
/// <summary>
/// Get v7 backdoor logins
/// </summary>
/// <returns>override pw</returns>
[HttpGet("v7-override")]
public ActionResult GetBackDoor()
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
LicenseBiz biz = LicenseBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
return Ok(ApiOkResponse.Response(new
{
today = Generate(DateTime.Today, new Random(unchecked((int)DateTime.Now.Ticks))),
tomorrow = Generate(DateTime.Today.AddDays(1), new Random(~unchecked((int)DateTime.Now.Ticks)))
}));
}
//------------
private string Generate(DateTime dtWhen, Random r)
{
int nDummyCharFactor = 4;
int ndwf = 0;
StringBuilder sb = new StringBuilder();
string sLogin = "";
string sPassword = "";
switch (dtWhen.DayOfWeek)
{
case System.DayOfWeek.Monday:
ndwf = 12;
break;
case System.DayOfWeek.Tuesday:
ndwf = 49;
break;
case System.DayOfWeek.Wednesday:
ndwf = 23;
break;
case System.DayOfWeek.Thursday:
ndwf = 65;
break;
case System.DayOfWeek.Friday:
ndwf = 87;
break;
case System.DayOfWeek.Sunday:
ndwf = 99;
break;
case System.DayOfWeek.Saturday:
ndwf = 72;
break;
}
int nLogin = dtWhen.DayOfYear + ndwf * ndwf;
int nPassword = (dtWhen.Year + dtWhen.Month + ndwf) * (ndwf + 2);
char dummy = ' ';
foreach (char c in nLogin.ToString())
{
int nDummycharcount = r.Next(nDummyCharFactor) + 1;
for (int x = 0; x < nDummycharcount; x++)
{
dummy = (char)(r.Next(26) + 65);
sLogin += dummy;
}
sLogin += c;
}
sb.Append("Login:[");
sb.Append(sLogin);
sb.Append("]\r\n");
//Do password
foreach (char c in nPassword.ToString())
{
int nDummycharcount = r.Next(nDummyCharFactor) + 1;
for (int x = 0; x < nDummycharcount; x++)
{
dummy = (char)(r.Next(26) + 65);
sPassword += dummy;
}
sPassword += c;
}
sb.Append("Password:[");
sb.Append(sPassword);
sb.Append("]\r\n");
return sb.ToString();
}
}//eoc
}//eons

View File

@@ -22,6 +22,7 @@ search:
DTR
- Add ui to front the route under /license/v7-override
License routes test locally and ensure works for v7 and v8
automatic jobs to create purchase record from vendor data
send license emails based on event etc, really gets into the new stuff here