public Auth0User GetUser()
        {
            IReadOnlyList <PasswordCredential> credentials;

            try
            {
                credentials = _vault.FindAllByResource(Resource);
            }
            catch (Exception)
            {
                return(null);
            }

            var credential = credentials.First();

            credential.RetrievePassword();

            var user = CacheHelpers.DecodeAuthUser(credential.Password);

            return(user);
        }
        public void StoreUser(Auth0User user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            var credential = GetFromVault(user.Profile["email"].ToString());

            if (credential != null)
            {
                _vault.Remove(credential);
            }

            var newCred = new PasswordCredential
            {
                UserName = user.Profile["email"].ToString(),
                Password = CacheHelpers.EncodeAuthUser(user),
                Resource = Resource
            };

            _vault.Add(newCred);
        }