This commit is contained in:
@@ -9,6 +9,8 @@ using System.Linq;
|
|||||||
using Sockeye.Models;
|
using Sockeye.Models;
|
||||||
using Sockeye.Api.ControllerHelpers;
|
using Sockeye.Api.ControllerHelpers;
|
||||||
using Sockeye.Biz;
|
using Sockeye.Biz;
|
||||||
|
using System.Text;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
namespace Sockeye.Api.Controllers
|
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
|
}//eoc
|
||||||
|
|
||||||
}//eons
|
}//eons
|
||||||
1
todo.txt
1
todo.txt
@@ -22,6 +22,7 @@ search:
|
|||||||
|
|
||||||
|
|
||||||
DTR
|
DTR
|
||||||
|
- Add ui to front the route under /license/v7-override
|
||||||
License routes test locally and ensure works for v7 and v8
|
License routes test locally and ensure works for v7 and v8
|
||||||
automatic jobs to create purchase record from vendor data
|
automatic jobs to create purchase record from vendor data
|
||||||
send license emails based on event etc, really gets into the new stuff here
|
send license emails based on event etc, really gets into the new stuff here
|
||||||
|
|||||||
Reference in New Issue
Block a user