public ActionResult GetCode([FromHeader(Name = "Device-ID")] Guid deviceId, [FromHeader(Name = "Authorization")] string token) { var accountDevice = new AccountDevice(deviceId, token, Guid.Empty); if (!ApplicationStateAccess.TryGetAccount(accountDevice, out var account)) { return(new UnauthorizedResult()); } byte[] tokenData = new byte[4]; Rng.GetBytes(tokenData); var timedAccountCode = new TimedAccountCode(ByteArrayToHexString(tokenData), DateTimeOffset.UtcNow.AddMinutes(1), account.Id); ApplicationStateAccess.AddTimedAccountCode(timedAccountCode); return(new JsonResult(new AccountCodeResponseDto { Code = timedAccountCode.Code, ValidUntil = timedAccountCode.ValidUntil })); }
public static void AddTimedAccountCode(TimedAccountCode timedAccountCode) { timedAccountCodes.Add(timedAccountCode); }
protected bool Equals(TimedAccountCode other) { return(string.Equals(Code, other.Code)); }