public static RSG GetRsg(string raw) { var rsgMatch = Regex.Match(raw, RsgPatt); var rsg = new RSG(raw); rsg.IsSnowClosed = rsgMatch.Groups["snow"].Success; rsg.Runway = new Runway(rsgMatch.Groups["rwy"].Value); var rwy = int.Parse(rsgMatch.Groups["rwy"].Value); if (rwy == 88) { rsg.Runway.IsAll = true; } else if (rwy > 36) { rsg.Runway.Rwy = rwy - 50; rsg.Runway.Designator = Designator.Right; } else { rsg.Runway.Rwy = rwy; if (rsgMatch.Groups["des"].Success) { switch (rsgMatch.Groups["des"].Value) { case "L": rsg.Runway.Designator = Designator.Left; break; case "C": rsg.Runway.Designator = Designator.Center; break; case "R": rsg.Runway.Designator = Designator.Right; break; } } } rsg.IsCleared = rsgMatch.Groups["clear"].Success; rsg.Deposit = rsgMatch.Groups["dep"].Value; rsg.Contamination = rsgMatch.Groups["cont"].Value; rsg.DepositDepth = rsgMatch.Groups["depth"].Value; rsg.BrakingAction = rsgMatch.Groups["coef"].Value; return(rsg); }
public async Task SendOneTimePassword(User user) { string otp = RSG.Generate(8); dbContext.OneTimePasswordForLogin.Add(new OneTimePasswordForLogin { Id = Guid.NewGuid(), User = user, Password = otp, CreatedOn = DateTime.UtcNow, }); dbContext.SaveChanges(); var email = new MailBuilder(this.mailConfig) .AddRecipients(user.Username) .WithSubject("New Requestr login") .WithBody($"Your login code is: {otp}") .Build(); if (!await this.emailService.SendMail(email)) { throw new Exception("One time password could not be sent."); } }
private (string password, string salt) Hash(string password) { string salt = RSG.Generate(16); return(Hash(password, salt), salt); }