public RssReaderUser GetUser(string username) { RssReaderUser user; using (db = new RssReaderDbContext()) { user = db.RssReaderUsers.FirstOrDefault(u => u.Username == username); return user; } }
public RssReaderUser GetUser(string username) { RssReaderUser user; using (db = new RssReaderDbContext()) { user = db.RssReaderUsers.FirstOrDefault(u => u.Username == username); return(user); } }
public void CreateUser(string username, string password) { var passwordProvider = new PasswordProvider(); string salt = passwordProvider.CreateSalt(); string hashedPassword = passwordProvider.CreateHashedPassword(username, salt); using (db = new RssReaderDbContext()) { db.RssReaderUsers.Add(new RssReaderUser(username, hashedPassword, salt)); db.SaveChanges(); } }
public override bool ValidateUser(string username, string password) { RssReaderUser user; if (!(IsNullOrEmpty(username) && IsNullOrEmpty(password))) { return false; } else { passwordProvider = new PasswordProvider(); using (db = new RssReaderDbContext()) { user = usersRepository.GetUser(username); if (user == null) //user does not exist { return false; } string hashedPassword = passwordProvider.CreateHashedPassword(password, user.Salt); return hashedPassword == user.Password; } } }