コード例 #1
0
ファイル: Users.cs プロジェクト: Eric-Zhang3/ExhibFlat1.0
        public static CreateUserStatus CreateOnlyDistributorUser(IUser user, string roles)
        {
            CreateUserStatus unknownFailure = UserHelper.CreateOnlyDistributor(user.MembershipUser, new string[] { roles });

            if ((unknownFailure == CreateUserStatus.Created) && !DistributorFactory.Instance().Create(user))
            {
                HiMembership.Delete(user.Username);
                unknownFailure = CreateUserStatus.UnknownFailure;
            }
            return(unknownFailure);
        }
コード例 #2
0
        public static CreateUserStatus CreateUser(IUser user, string[] roles)
        {
            CreateUserStatus unknownFailure = UserHelper.Create(user.MembershipUser, roles);

            if ((unknownFailure == CreateUserStatus.Created) && !UserFactory.Create(user.UserRole).Create(user))
            {
                HiMembership.Delete(user.Username);
                unknownFailure = CreateUserStatus.UnknownFailure;
            }
            return(unknownFailure);
        }
コード例 #3
0
        public static CreateUserStatus CreateUser(IUser user, string[] roles)
        {
            CreateUserStatus createUserStatus = UserHelper.Create(user.MembershipUser, roles);

            if (createUserStatus == CreateUserStatus.Created && !Class0.smethod_0(user.UserRole).vmethod_2(user))
            {
                HiMembership.Delete(user.Username);
                createUserStatus = CreateUserStatus.UnknownFailure;
            }
            return(createUserStatus);
        }
コード例 #4
0
ファイル: Users.cs プロジェクト: damoOnly/e-commerce
        public static CreateUserStatus CreateUser(IUser user, string[] roles)
        {
            CreateUserStatus createUserStatus = UserHelper.Create(user.MembershipUser, roles);

            if (createUserStatus == CreateUserStatus.Created)
            {
                UserFactory userFactory = UserFactory.Create(user.UserRole);
                if (!userFactory.Create(user))
                {
                    HiMembership.Delete(user.Username);
                    createUserStatus = CreateUserStatus.UnknownFailure;
                }
            }
            return(createUserStatus);
        }
コード例 #5
0
        public override CreateUserStatus CreateMembershipUser(HiMembershipUser userToCreate, string passwordQuestion, string passwordAnswer)
        {
            CreateUserStatus unknownFailure = CreateUserStatus.UnknownFailure;

            if (userToCreate == null)
            {
                return(CreateUserStatus.UnknownFailure);
            }
            bool flag = false;

            if (!string.IsNullOrEmpty(passwordQuestion) && !string.IsNullOrEmpty(passwordAnswer))
            {
                flag = true;
                if ((passwordAnswer.Length > 0x80) || (passwordQuestion.Length > 0x100))
                {
                    throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer);
                }
            }
            MembershipUser user = HiMembership.Create(userToCreate.Username, userToCreate.Password, userToCreate.Email);

            if (user != null)
            {
                userToCreate.UserId = (int)user.ProviderUserKey;
                DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_Users SET IsAnonymous = @IsAnonymous, IsApproved = @IsApproved, PasswordQuestion = @PasswordQuestion, PasswordAnswer = @PasswordAnswer, Gender = @Gender, BirthDate = @BirthDate, UserRole = @UserRole WHERE UserId = @UserId");
                this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, userToCreate.UserId);
                this.database.AddInParameter(sqlStringCommand, "IsAnonymous", DbType.Boolean, userToCreate.IsAnonymous);
                this.database.AddInParameter(sqlStringCommand, "IsApproved", DbType.Boolean, userToCreate.IsApproved);
                this.database.AddInParameter(sqlStringCommand, "Gender", DbType.Int32, (int)userToCreate.Gender);
                this.database.AddInParameter(sqlStringCommand, "BirthDate", DbType.DateTime, null);
                this.database.AddInParameter(sqlStringCommand, "UserRole", DbType.Int32, (int)userToCreate.UserRole);
                this.database.AddInParameter(sqlStringCommand, "PasswordQuestion", DbType.String, null);
                this.database.AddInParameter(sqlStringCommand, "PasswordAnswer", DbType.String, null);
                if (userToCreate.BirthDate.HasValue)
                {
                    this.database.SetParameterValue(sqlStringCommand, "BirthDate", userToCreate.BirthDate.Value);
                }
                if (flag)
                {
                    string str2 = null;
                    try
                    {
                        int    num;
                        int    num2;
                        string str;
                        this.GetPasswordWithFormat(userToCreate.Username, false, out num2, out num, out str);
                        if (num2 == 0)
                        {
                            str2 = UserHelper.EncodePassword((MembershipPasswordFormat)num, passwordAnswer, str);
                            this.database.SetParameterValue(sqlStringCommand, "PasswordQuestion", passwordQuestion);
                            this.database.SetParameterValue(sqlStringCommand, "PasswordAnswer", str2);
                        }
                        if ((num2 != 0) || (!string.IsNullOrEmpty(str2) && (str2.Length > 0x80)))
                        {
                            HiMembership.Delete(userToCreate.Username);
                            throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer);
                        }
                    }
                    catch
                    {
                        HiMembership.Delete(userToCreate.Username);
                        throw new CreateUserException(CreateUserStatus.UnknownFailure);
                    }
                }
                if (this.database.ExecuteNonQuery(sqlStringCommand) == 1)
                {
                    unknownFailure = CreateUserStatus.Created;
                }
                else
                {
                    HiMembership.Delete(userToCreate.Username);
                    throw new CreateUserException(unknownFailure);
                }
            }
            return(unknownFailure);
        }
コード例 #6
0
ファイル: UserData.cs プロジェクト: uvbs/eshopSanQiang
        public override CreateUserStatus CreateMembershipUser(HiMembershipUser userToCreate, string passwordQuestion, string passwordAnswer)
        {
            CreateUserStatus createUserStatus = CreateUserStatus.UnknownFailure;
            CreateUserStatus result;

            if (userToCreate == null)
            {
                result = CreateUserStatus.UnknownFailure;
            }
            else
            {
                bool flag = false;
                if (!string.IsNullOrEmpty(passwordQuestion) && !string.IsNullOrEmpty(passwordAnswer))
                {
                    flag = true;
                    if (passwordAnswer.Length > 128 || passwordQuestion.Length > 256)
                    {
                        throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer);
                    }
                }
                MembershipUser membershipUser = HiMembership.Create(userToCreate.Username, userToCreate.Password, userToCreate.Email);
                if (membershipUser != null)
                {
                    userToCreate.UserId = (int)membershipUser.ProviderUserKey;
                    System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_Users SET IsAnonymous = @IsAnonymous, IsApproved = @IsApproved, PasswordQuestion = @PasswordQuestion, PasswordAnswer = @PasswordAnswer, Gender = @Gender, BirthDate = @BirthDate, UserRole = @UserRole WHERE UserId = @UserId");
                    this.database.AddInParameter(sqlStringCommand, "UserId", System.Data.DbType.Int32, userToCreate.UserId);
                    this.database.AddInParameter(sqlStringCommand, "IsAnonymous", System.Data.DbType.Boolean, userToCreate.IsAnonymous);
                    this.database.AddInParameter(sqlStringCommand, "IsApproved", System.Data.DbType.Boolean, userToCreate.IsApproved);
                    this.database.AddInParameter(sqlStringCommand, "Gender", System.Data.DbType.Int32, (int)userToCreate.Gender);
                    this.database.AddInParameter(sqlStringCommand, "BirthDate", System.Data.DbType.DateTime, null);
                    this.database.AddInParameter(sqlStringCommand, "UserRole", System.Data.DbType.Int32, (int)userToCreate.UserRole);
                    this.database.AddInParameter(sqlStringCommand, "PasswordQuestion", System.Data.DbType.String, null);
                    this.database.AddInParameter(sqlStringCommand, "PasswordAnswer", System.Data.DbType.String, null);
                    if (userToCreate.BirthDate.HasValue)
                    {
                        this.database.SetParameterValue(sqlStringCommand, "BirthDate", userToCreate.BirthDate.Value);
                    }
                    if (flag)
                    {
                        string text = null;
                        try
                        {
                            int    num;
                            int    format;
                            string salt;
                            this.GetPasswordWithFormat(userToCreate.Username, false, out num, out format, out salt);
                            if (num == 0)
                            {
                                text = UserHelper.EncodePassword((MembershipPasswordFormat)format, passwordAnswer, salt);
                                this.database.SetParameterValue(sqlStringCommand, "PasswordQuestion", passwordQuestion);
                                this.database.SetParameterValue(sqlStringCommand, "PasswordAnswer", text);
                            }
                            if (num != 0 || (!string.IsNullOrEmpty(text) && text.Length > 128))
                            {
                                HiMembership.Delete(userToCreate.Username);
                                throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer);
                            }
                        }
                        catch
                        {
                            HiMembership.Delete(userToCreate.Username);
                            throw new CreateUserException(CreateUserStatus.UnknownFailure);
                        }
                    }
                    if (this.database.ExecuteNonQuery(sqlStringCommand) != 1)
                    {
                        HiMembership.Delete(userToCreate.Username);
                        throw new CreateUserException(createUserStatus);
                    }
                    createUserStatus = CreateUserStatus.Created;
                }
                result = createUserStatus;
            }
            return(result);
        }