public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion,
            string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            if (string.IsNullOrWhiteSpace(password))
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            MembershipUser user = GetUser(username, true);

            if (user == null)
            {
                var userLogin = new UserLogin();
                userLogin.User.Name = username;
                userLogin.Password = password; //GetMD5Hash(password);
                userRepository.AddUser(userLogin);

                status = MembershipCreateStatus.Success;

                return GetUser(username, true);
            }
            else
            {
                status = MembershipCreateStatus.DuplicateUserName;
            }

            return null;
        }
Esempio n. 2
0
        public void AddUser(UserLogin userLogin)
        {
            if (userLogin == null)
            {
                throw new ArgumentException("userLogin");
            }

            using (var context = new PressfordContext())
            {
                context.UserLogins.Add(userLogin);
                context.SaveChanges();
            }
        }