コード例 #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
ファイル: UsersService.cs プロジェクト: skakkar12/MVCCode
 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;
        }
コード例 #4
0
 void IDatabaseContext.Add(Membership membership)
 {
     this.Set<Membership>().Add(membership);
 }