Beispiel #1
0
        public static string GetSalt(string username)
        {
            string salt;

            try
            {
                var dataAccess      = GenericDataAccess.GetDatabase();
                var mongoCollection = GetMongoDBCollection <User> .GetDatabaseCollection(dataAccess, "Users");

                salt = mongoCollection.Find(x => x.UserName == username).FirstOrDefault().Salt;
                // check how can you select the salt value from json/single value
                if (salt == null)
                {
                    throw new MongoDBDataAccessException("Unable to find salt for respective user");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }

            return(salt);
        }