コード例 #1
0
 public RssReaderUser GetUser(string username)
 {
     RssReaderUser user;
     using (db = new RssReaderDbContext())
     {
         user = db.RssReaderUsers.FirstOrDefault(u => u.Username == username);
         return user;
     }
 }
コード例 #2
0
        public RssReaderUser GetUser(string username)
        {
            RssReaderUser user;

            using (db = new RssReaderDbContext())
            {
                user = db.RssReaderUsers.FirstOrDefault(u => u.Username == username);
                return(user);
            }
        }
コード例 #3
0
        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();
            }
        }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
 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;
         }
     }
 }