protected MembershipUser GetMembershipUser(User userRecord) { return new MembershipUser("MongoMembershipProvider", userRecord.Username, userRecord.Id, userRecord.Email, userRecord.PasswordQuestion, userRecord.Comment, userRecord.IsApproved, userRecord.IsLockedOut, userRecord.CreationDate, userRecord.LastLoginDate, userRecord.LastLockedOutDate, userRecord.LastPasswordChangedDate, userRecord.LastLockedOutDate); }
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { if (Users.All().Any(x => x.Username == username)) { status = MembershipCreateStatus.DuplicateUserName; return null; } if (Users.All().Any(x => x.Email.ToUpper() == email.ToUpper())) { status = MembershipCreateStatus.DuplicateEmail; return null; } string passwordHash = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "sha1"); var user = new User { Username = username, Email = email, PasswordHash = passwordHash, PasswordQuestion = passwordQuestion, PasswordAnswer = passwordAnswer, IsApproved = isApproved, Comment = string.Empty, IsLockedOut = false, CreationDate = DateTime.Now, LastLoginDate = DateTime.Now, LastActivityDate = DateTime.Now, LastLockedOutDate = DateTime.Now, LastPasswordChangedDate = DateTime.Now }; Users.Add(user); // not sure if this sets id status = MembershipCreateStatus.Success; return GetMembershipUser(user); }