private bool VerifyPasswordAnswer(User user, string passwordAnswer)
 {
     return user.PasswordAnswer == EncodePassword(passwordAnswer, this.PasswordFormat, user.PasswordSalt);
 }
 private bool IsPasswordCorrect(User user, string password)
 {
     System.Diagnostics.Debug.Write("---> check pass " + user.Password == EncodePassword(password, this.PasswordFormat, user.PasswordSalt) + "\n");
     return user.Password == EncodePassword(password, this.PasswordFormat, user.PasswordSalt);
 }
        private MembershipUser ToMembershipUser(User user)
        {
            if (user == null)
                return null;

            return new MembershipUser(Name, user.Username, user.Id, user.Email, user.PasswordQuestion, user.Comment, user.IsApproved, user.IsLockedOut, user.CreateDate, user.LastLoginDate, user.LastActivityDate, user.LastPasswordChangedDate, user.LastLockedOutDate);
        }
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            if (providerUserKey == null)
            {
                providerUserKey = Guid.NewGuid();
            }

            var validatePasswordEventArgs = new ValidatePasswordEventArgs(username, password, true);
            OnValidatingPassword(validatePasswordEventArgs);

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

            if (this.RequiresQuestionAndAnswer)
            {
                if (passwordQuestion.IsNullOrWhiteSpace())
                {
                    status = MembershipCreateStatus.InvalidQuestion;
                    return null;
                }
                if (passwordAnswer.IsNullOrWhiteSpace())
                {
                    status = MembershipCreateStatus.InvalidAnswer;
                    return null;
                }
            }

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

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

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

            var buffer = new byte[16];
            buffer.RngGenerator();
            var passwordSalt = buffer.ToBase64String();

            var createDate = DateTime.UtcNow;
            var user = new User
            {
                CreateDate = createDate,
                CreatePerson = ObjectId.Empty,
                LastPasswordChangedDate = createDate,
                LastPasswordChangePerson = ObjectId.Empty,
                Status = 1,
                Username = username,
                Password = EncodePassword(password, this.PasswordFormat, passwordSalt),
                UserType = 1,
                UserFullname = "Need to insert later",
                UserPhone = "Need to insert later",
                Email = email,
                UserAddress = "Need to insert later",
                Comment = "Need to insert later",
                UserContactPerson = "Need to insert later",
                UserContactPhone = "Need to insert later",
                UserTimeZone = 7,

                FailedPasswordAnswerAttemptCount = 0,
                FailedPasswordAnswerAttemptWindowStart = createDate,
                FailedPasswordAttemptCount = 0,
                FailedPasswordAttemptWindowStart = createDate,
                IsApproved = isApproved,
                IsDeleted = false,
                IsLockedOut = false,
                LastActivityDate = createDate,
                LastLockedOutDate = new DateTime(1970, 1, 1),
                LastLoginDate = createDate,
                PasswordAnswer = EncodePassword(passwordAnswer, this.PasswordFormat, passwordSalt),
                PasswordQuestion = passwordQuestion,
                PasswordSalt = passwordSalt,
            };

            this.mongoGateway.CreateUser(user);
            status = MembershipCreateStatus.Success;
            return GetUser(username, false);
        }
Example #5
0
 public void CreateUser(User user)
 {
     UsersCollection.Insert(user);
 }
Example #6
0
 public void UpdateUser(User user)
 {
     UsersCollection.Save(user);
 }
Example #7
0
 public void RemoveUser(User user)
 {
     user.IsDeleted = true;
     UpdateUser(user);
 }
 private static ProfileInfo ToProfileInfo(User user)
 {
     //return new ProfileInfo(user.Username, user.IsAnonymous, user.LastActivityDate, user.LastUpdatedDate, 0);
     return null;
 }