Exemple #1
0
 public override int GetNumberOfUsersOnline()
 {
     using (GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer(connectionString))
     {
         return(0);
     }
 }
Exemple #2
0
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true);

            OnValidatingPassword(args);

            if (args.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            if (RequiresUniqueEmail && !string.IsNullOrEmpty(GetUserNameByEmail(email)))
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return(null);
            }

            if (GetUser(username, false) != null)
            {
                status = MembershipCreateStatus.DuplicateUserName;
                return(null);
            }

            using (GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer(connectionString))
            {
                container.AddToUsers(new User()
                {
                });
                status = MembershipCreateStatus.Success;
                return(GetUser(username, false));
            }
        }
Exemple #3
0
        public override bool ChangePassword(string username, string oldPwd, string newPwd)
        {
            if (!ValidateUser(username, oldPwd))
            {
                return(false);
            }

            ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, newPwd, true);

            OnValidatingPassword(args);

            if (args.Cancel)
            {
                throw args.FailureInformation ?? new MembershipPasswordException("Change password canceled due to new password validation failure.");
            }

            using (GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer(connectionString))
            {
                User user = GetUser(container, username, EncodePassword(oldPwd));

                if (user == null)
                {
                    return(false);
                }

                user.LoginCredentials.Password = EncodePassword(newPwd);
                container.AcceptAllChanges();
                container.SaveChanges();
                return(true);
            }
        }
Exemple #4
0
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            using (GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer(connectionString))
            {
                totalRecords = container.Users.Count();
                GhostmonkMembershipUser user = new GhostmonkMembershipUser("", "", "", "", "", "", true, false, DateTime.Now(), );

                return(new MembershipUserCollection());
            }
        }
Exemple #5
0
 public override bool DeleteUser(string username, bool deleteAllRelatedData)
 {
     using (GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer(connectionString))
     {
         User user = (from u in container.Users where u.LoginCredentials.UserName == username select u).FirstOrDefault();
         if (user == null)
         {
             return(false);
         }
         container.DeleteObject(user.LoginCredentials);
         container.DeleteObject(user);
         container.AcceptAllChanges();
         return(container.SaveChanges() > 0);
     }
 }
Exemple #6
0
        public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPwdQuestion, string newPwdAnswer)
        {
            if (!ValidateUser(username, password))
            {
                return(false);
            }

            using (GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer(connectionString))
            {
                User user = GetUser(container, username, password);
                user.LoginCredentials.PasswordQuestion = newPwdQuestion;
                user.LoginCredentials.PasswordAnswer   = newPwdAnswer;
                container.AcceptAllChanges();
                return(container.SaveChanges() > 0);
            }
        }
 public override string GetUserNameByEmail( string email )
 {
     using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
     {
         return (from user in container.Users
                 where user.Email == email
                 select user.LoginCredentials.UserName).FirstOrDefault();
     }
 }
 public override MembershipUser GetUser( object providerUserKey, bool userIsOnline )
 {
     using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
     {
         return null;
     }
 }
        public override string GetPassword( string username, string answer )
        {
            if( !EnablePasswordRetrieval )
                throw new ProviderException( "Password Retrieval Not Enabled." );

            if( PasswordFormat == MembershipPasswordFormat.Hashed )
                throw new ProviderException( "Cannot retrieve Hashed passwords." );

            using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
            {
                User user = ( from u in container.Users
                              where u.LoginCredentials.UserName == username
                              select u ).FirstOrDefault();

                if( user == null )
                    throw new MembershipPasswordException( "Cannot find user" );

                if( user.LoginCredentials.PasswordAnswer != answer )
                {
                    UpdateFailureCount( username, "Incorrect Answer" );
                    throw new MembershipPasswordException( "Provided answer does not match our record." );
                }
                return PasswordFormat == MembershipPasswordFormat.Encrypted
                    ? UnEncodePassword( user.LoginCredentials.Password )
                    : user.LoginCredentials.Password;
            }
        }
 public override int GetNumberOfUsersOnline()
 {
     using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
     {
         return 0;
     }
 }
 private User GetUser( GhostmonkMainSiteModelContainer container, string username, string password )
 {
     string encodedPassword = EncodePassword( password );
     return ( from user in container.Users
                 where user.LoginCredentials.UserName == username && user.LoginCredentials.Password == encodedPassword
                 select user ).FirstOrDefault();
 }
        public override void UpdateUser( MembershipUser user )
        {
            using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
            {

            }
        }
        public override MembershipUser CreateUser( string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status )
        {
            ValidatePasswordEventArgs args = new ValidatePasswordEventArgs( username, password, true );
            OnValidatingPassword( args );

            if( args.Cancel )
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            if( RequiresUniqueEmail && !string.IsNullOrEmpty( GetUserNameByEmail( email ) ) )
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return null;
            }

            if( GetUser( username, false ) != null )
            {
                status = MembershipCreateStatus.DuplicateUserName;
                return null;
            }

            using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
            {
                container.AddToUsers( new User(){  } );
                status = MembershipCreateStatus.Success;
                return GetUser( username, false );
            }
        }
        public override bool ChangePasswordQuestionAndAnswer( string username, string password, string newPwdQuestion, string newPwdAnswer )
        {
            if( !ValidateUser( username, password ) ) return false;

            using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
            {
                User user = GetUser( container, username, password );
                user.LoginCredentials.PasswordQuestion = newPwdQuestion;
                user.LoginCredentials.PasswordAnswer = newPwdAnswer;
                container.AcceptAllChanges();
                return container.SaveChanges() > 0;
            }
        }
        public override bool ChangePassword( string username, string oldPwd, string newPwd )
        {
            if( !ValidateUser( username, oldPwd ) ) return false;

            ValidatePasswordEventArgs args = new ValidatePasswordEventArgs( username, newPwd, true );
            OnValidatingPassword( args );

            if( args.Cancel )
                throw args.FailureInformation ?? new MembershipPasswordException( "Change password canceled due to new password validation failure." );

            using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
            {
                User user = GetUser( container, username, EncodePassword( oldPwd ) );

                if( user == null ) return false;

                user.LoginCredentials.Password = EncodePassword( newPwd );
                container.AcceptAllChanges();
                container.SaveChanges();
                return true;
            }
        }
        public override string ResetPassword( string username, string answer )
        {
            if( !EnablePasswordReset )
                throw new NotSupportedException( "Password reset is not enabled." );

            if( answer == null && RequiresQuestionAndAnswer )
            {
                UpdateFailureCount( username, "passwordAnswer" );
                throw new ProviderException( "Password answer required for password reset." );
            }

            string newPassword = Membership.GeneratePassword( NEW_PASSWORD_LENGTH, MinRequiredNonAlphanumericCharacters );

            var args = new ValidatePasswordEventArgs( username, newPassword, true );
            OnValidatingPassword( args );

            if( args.Cancel )
                throw args.FailureInformation ?? new MembershipPasswordException( "Reset password canceled due to password validation failure." );

            using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
            {
                return string.Empty;
            }
        }
 public override bool UnlockUser( string username )
 {
     using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
     {
         return false;
     }
 }
 public override bool DeleteUser( string username, bool deleteAllRelatedData )
 {
     using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
     {
         User user = (from u in container.Users where u.LoginCredentials.UserName == username select u).FirstOrDefault();
         if( user == null ) return false;
         container.DeleteObject( user.LoginCredentials );
         container.DeleteObject( user );
         container.AcceptAllChanges();
         return container.SaveChanges() > 0;
     }
 }
 private User GetUser( string username, string password )
 {
     using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
     {
         return GetUser( container, username, password );
     }
 }
 public override MembershipUserCollection FindUsersByName( string usernameToMatch, int pageIndex, int pageSize, out int totalRecords )
 {
     using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
     {
         totalRecords = 0;
         return  new MembershipUserCollection();
     }
 }
        private void UpdateFailureCount( string username, string failureType )
        {
            using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
            {

            }
        }
        public override MembershipUserCollection GetAllUsers( int pageIndex, int pageSize, out int totalRecords )
        {
            using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
            {
                totalRecords = container.Users.Count();
                GhostmonkMembershipUser user = new GhostmonkMembershipUser( "", "", "", "", "", "", true, false, DateTime.Now(),  );

                return new MembershipUserCollection();
            }
        }