From e51c7a2a8e52bc3408665edcbb5f4259efb9488f Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 29 Dec 2022 21:48:21 +0000 Subject: [PATCH] --- server/Controllers/LicenseController.cs | 101 ++++++++++++++++++++++++ todo.txt | 1 + 2 files changed, 102 insertions(+) diff --git a/server/Controllers/LicenseController.cs b/server/Controllers/LicenseController.cs index 8b9e38b..576bde4 100644 --- a/server/Controllers/LicenseController.cs +++ b/server/Controllers/LicenseController.cs @@ -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 + + /// + /// Get v7 backdoor logins + /// + /// override pw + [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 \ No newline at end of file diff --git a/todo.txt b/todo.txt index 9130bb0..7a618fe 100644 --- a/todo.txt +++ b/todo.txt @@ -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