예제 #1
0
        public override string CreateUserAndAccount(string userName /*email*/, string password, bool requireConfirmation, IDictionary <string, object> values)
        {
            userName = userName.Trim().ToLower();

            var userProfile = this.usersService.GetUserProfile(userName);

            if (userProfile != null)
            {
                throw new MembershipCreateUserException(MembershipCreateStatus.DuplicateEmail);
            }

            var newUserProfile = new UserProfile {
                UserName = userName, DisplayName = userName
            };

            this.usersService.Save(newUserProfile);

            var membership = new App.Core.Data.Membership
            {
                UserId            = newUserProfile.UserId,
                CreateDate        = DateTime.Now,
                PasswordSalt      = this.usersService.GetHash(password),
                IsConfirmed       = false,
                ConfirmationToken = Guid.NewGuid().ToString().ToLower()
            };

            this.usersService.Save(membership, add: true);

            return(membership.ConfirmationToken);
        }
예제 #2
0
 void IUsersService.Save(App.Core.Data.Membership membership, bool add)
 {
     if (add)
     {
         this.db.Add(membership);
     }
     this.db.SaveChanges();
 }
        public override string CreateUserAndAccount(string userName/*email*/, string password, bool requireConfirmation, IDictionary<string, object> values)
        {
            userName = userName.Trim().ToLower();

            var userProfile = this.usersService.GetUserProfile(userName);
            if (userProfile != null)
            {
                throw new MembershipCreateUserException(MembershipCreateStatus.DuplicateEmail);
            }

            var newUserProfile = new UserProfile { UserName = userName, DisplayName = userName };
            this.usersService.Save(newUserProfile);

            var membership = new App.Core.Data.Membership
            {
                UserId = newUserProfile.UserId,
                CreateDate = DateTime.Now,
                PasswordSalt = this.usersService.GetHash(password),
                IsConfirmed = false,
                ConfirmationToken = Guid.NewGuid().ToString().ToLower()
            };
            this.usersService.Save(membership, add: true);

            return membership.ConfirmationToken;
        }
 void IDatabaseContext.Add(Membership membership)
 {
     this.Set<Membership>().Add(membership);
 }