public static void InsertLoginAttempt(string ipaddress) { using (EFDbContext context = new EFDbContext()) { LoginAttempts la = new LoginAttempts(); la.ClientIP = ipaddress; la.Unlocked = 0; la.DateAdded = DateTime.Now; context.loginAttempts.Add(la); context.SaveChanges(); } }
public static bool UpdateLoginRecord(IProcessor processor, string email, string username, int uid) { bool valid = false; try { // generate new password string newPasword = Reusables.GetPassword(); // update login record MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider(); byte[] hashedDataBytes = null; UTF8Encoding encoder = new UTF8Encoding(); hashedDataBytes = md5Hasher.ComputeHash(encoder.GetBytes(newPasword)); using (EFDbContext context = new EFDbContext()) { var login = (from l in context.logins where l.UID == uid select l).FirstOrDefault(); if (login != null) { login.Errors = 0; login.Modified_On = DateTime.Now; login.EncryptedPassword = hashedDataBytes; // *** marked out for testing context.SaveChanges(); } } // send welcome email processor.ProcessNewPasswordSendEmail(email, username, newPasword); valid = true; } catch (Exception ex) { } return valid; }
public static void IncrementErrors(int uid) { using (EFDbContext context = new EFDbContext()) { var login = (from l in context.logins where l.UID == uid select l).FirstOrDefault(); if (login != null) { login.Errors = login.Errors + 1; login.Modified_On = DateTime.Now; context.SaveChanges(); } } }