当前位置: 首页>>代码示例>>C#>>正文


C# ModelUser.Update方法代码示例

本文整理汇总了C#中ModelUser.Update方法的典型用法代码示例。如果您正苦于以下问题:C# ModelUser.Update方法的具体用法?C# ModelUser.Update怎么用?C# ModelUser.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelUser的用法示例。


在下文中一共展示了ModelUser.Update方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateUserImp

        internal static void UpdateUserImp(string userName, string password, string email, string secretQuestion,
            string secretAnswer, bool enabled, string SessionToken)
        {
            if (String.IsNullOrEmpty(userName) ||
                String.IsNullOrEmpty(password) ||
                String.IsNullOrEmpty(email) ||
                String.IsNullOrEmpty(secretQuestion) ||
                String.IsNullOrEmpty(secretAnswer))
            {
                throw new InvalidOperationException("One of the requested fields is empty.");
            }

            if (userName.ToLowerInvariant() == "everyone")
                throw new InvalidOperationException("Anonymous user update is not allowed.");

            ModelSession session = CheckSessionImp(SessionToken);

            if (CheckUserRightsImp(session.User.Name, "ManageUsers"))
            {
                ModelUser mu = new ModelUser(userName);

                if (!mu.Exists)
                    throw new InvalidOperationException("User does not exist.");

                mu.PasswordHash = Platform.Runtime.Security.Hash.ComputeHash(password, "SHA512", null);
                mu.Email = email;
                mu.SecretQuestion = secretQuestion;
                mu.SecretAnswer = secretAnswer;
                mu.Enabled = enabled;
                mu.Update();

                return;
            }

            throw new UnauthorizedAccessException("Access Denied");
        }
开发者ID:phaetto,项目名称:services-update,代码行数:36,代码来源:Services.Packages.Log.Security.ApplicationExceptionSecureService.cs

示例2: CreateRandomPasswordImp

        internal static string CreateRandomPasswordImp(string userName, string answer, string SessionToken)
        {
            // This must change - only anonymous can request new account
            // Must be sent in the email address <- We do not know the delivery of password here :-(

            if (String.IsNullOrEmpty(userName) ||
                String.IsNullOrEmpty(answer))
            {
                throw new InvalidOperationException("One of the requested fields is empty.");
            }

            if (userName.ToLowerInvariant() == "everyone")
                throw new InvalidOperationException("Anonymous user cannot have a password.");

            ModelSession session = CheckSessionImp(SessionToken);

            if (CheckUserRightsImp(session.User.Name, "ManageUsers")) // this should be removed - must be only everyone
            {
                ModelUser mu = new ModelUser(userName);

                if (!mu.Exists)
                    throw new InvalidOperationException("User does not exist.");

                if (mu.SecretAnswer.ToLowerInvariant() == answer.ToLowerInvariant())
                {
                    string password = GeneratePasswordImp();

                    mu.PasswordHash = Platform.Runtime.Security.Hash.ComputeHash(password, "SHA512", null);
                    mu.Update();

                    return password;
                }
            }

            throw new UnauthorizedAccessException("Access Denied");
        }
开发者ID:phaetto,项目名称:services-update,代码行数:36,代码来源:Services.Packages.Log.Security.ApplicationExceptionSecureService.cs

示例3: CreateFromOwner

        public ModelUser CreateFromOwner(System.String __Name, Services.Packages.Security.ModelUser _Owner, string SessionToken)
        {
            ModelSession session = ModelUserSecureService.CheckSessionImp(SessionToken);

            ModelUser _ModelUser = new ModelUser(__Name);

            if (!_ModelUser.Exists && !Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_Owner, SessionToken, "Create ModelUserOwning"))
                throw new UnauthorizedAccessException("Access Denied");
            else if (_ModelUser.Exists && !ModelUserSecureService.CheckAccessImp(_ModelUser, SessionToken, "Update"))
                throw new UnauthorizedAccessException("Access Denied");

            // ModelUser _ModelUser = ModelUser.CreateModelUser(__Name);
            _ModelUser.Owner = session.User;
            _ModelUser.Owner = _Owner;
            _ModelUser.Update();
            return _ModelUser;
        }
开发者ID:phaetto,项目名称:services-update,代码行数:17,代码来源:Services.Packages.Security.Security.ModelUserSecureService.cs

示例4: ChangePasswordImp

        internal static void ChangePasswordImp(string userName, string oldPassword, string newPassword, string SessionToken)
        {
            if (String.IsNullOrEmpty(userName) ||
                String.IsNullOrEmpty(oldPassword) ||
                String.IsNullOrEmpty(newPassword))
            {
                throw new InvalidOperationException("One of the requested fields is empty.");
            }

            if (userName.ToLowerInvariant() == "everyone")
                throw new InvalidOperationException("Anonymous user cannot have a password.");

            ModelSession session = CheckSessionImp(SessionToken);

            if ( (session.User.Name == userName) ||
                CheckUserRightsImp(session.User.Name, "ManageUsers"))
            {
                ModelUser mu = new ModelUser(userName);

                string oldPasswordHash = Platform.Runtime.Security.Hash.ComputeHash(oldPassword, "SHA512", null);

                if (mu.PasswordHash != oldPasswordHash)
                    throw new InvalidOperationException("Old password is invalid.");

                if (!mu.Exists)
                    throw new InvalidOperationException("User does not exist.");

                mu.PasswordHash = Platform.Runtime.Security.Hash.ComputeHash(newPassword, "SHA512", null);
                mu.Update();

                return;
            }

            throw new UnauthorizedAccessException("Access Denied");
        }
开发者ID:phaetto,项目名称:services-update,代码行数:35,代码来源:Services.Packages.Log.Security.ApplicationExceptionSecureService.cs

示例5: SetACLs

            public void SetACLs(ModelUser _ModelUser, Services.Packages.Security.Security.ModelUserAccessControlListCollection _ACLs, string SessionToken)
            {
                _ModelUser.Reload();

                //*
                if (!Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_ModelUser, SessionToken, "Traverse"))
                throw new UnauthorizedAccessException("Access Denied");
                //*/

                /*
                _ACLs.Reload();
                if (_ACLs.Exists && !Services.Packages.Security.Security.Security.ModelUserAccessControlListSecureService.CheckAccessImp(_ACLs, SessionToken, "Update"))
                throw new UnauthorizedAccessException("Access Denied");
                else if (!_ACLs.Exists && !Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_ModelUser, SessionToken, "Create ACLs"))
                throw new UnauthorizedAccessException("Access Denied");
                //*/

                _ModelUser.ACLs = _ACLs;
                _ModelUser.Update();
            }
开发者ID:phaetto,项目名称:services-update,代码行数:20,代码来源:Services.Packages.Security.Security.ModelUserSecureService.cs

示例6: SetRights

            public void SetRights(ModelUser _ModelUser, Services.Packages.Security.ModelUserRightsCollection _Rights, string SessionToken)
            {
                _ModelUser.Reload();

                //*
                if (!Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_ModelUser, SessionToken, "Traverse"))
                throw new UnauthorizedAccessException("Access Denied");
                //*/

                /*
                _Rights.Reload();
                if (_Rights.Exists && !Services.Packages.Security.Security.ModelUserRightsSecureService.CheckAccessImp(_Rights, SessionToken, "Update"))
                throw new UnauthorizedAccessException("Access Denied");
                else if (!_Rights.Exists && !Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_ModelUser, SessionToken, "Create Rights"))
                throw new UnauthorizedAccessException("Access Denied");
                //*/

                _ModelUser.Rights = _Rights;
                _ModelUser.Update();
            }
开发者ID:phaetto,项目名称:services-update,代码行数:20,代码来源:Services.Packages.Security.Security.ModelUserSecureService.cs

示例7: SetModelUserOwning

            public void SetModelUserOwning(ModelUser _ModelUser, Services.Packages.Security.ModelUserCollection _ModelUserOwning, string SessionToken)
            {
                _ModelUser.Reload();

                //*
                if (!Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_ModelUser, SessionToken, "Traverse"))
                throw new UnauthorizedAccessException("Access Denied");
                //*/

                /*
                _ModelUserOwning.Reload();
                if (_ModelUserOwning.Exists && !Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_ModelUserOwning, SessionToken, "Update"))
                throw new UnauthorizedAccessException("Access Denied");
                else if (!_ModelUserOwning.Exists && !Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_ModelUser, SessionToken, "Create ModelUserOwning"))
                throw new UnauthorizedAccessException("Access Denied");
                //*/

                _ModelUser.ModelUserOwning = _ModelUserOwning;
                _ModelUser.Update();
            }
开发者ID:phaetto,项目名称:services-update,代码行数:20,代码来源:Services.Packages.Security.Security.ModelUserSecureService.cs

示例8: SetCustomerUserEntries

            public void SetCustomerUserEntries(ModelUser _ModelUser, Services.Packages.CustomerUserEntryCollection _CustomerUserEntries, string SessionToken)
            {
                _ModelUser.Reload();

                //*
                if (!Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_ModelUser, SessionToken, "Traverse"))
                throw new UnauthorizedAccessException("Access Denied");
                //*/

                /*
                _CustomerUserEntries.Reload();
                if (_CustomerUserEntries.Exists && !Services.Packages.Security.CustomerUserEntrySecureService.CheckAccessImp(_CustomerUserEntries, SessionToken, "Update"))
                throw new UnauthorizedAccessException("Access Denied");
                else if (!_CustomerUserEntries.Exists && !Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_ModelUser, SessionToken, "Create CustomerUserEntries"))
                throw new UnauthorizedAccessException("Access Denied");
                //*/

                _ModelUser.CustomerUserEntries = _CustomerUserEntries;
                _ModelUser.Update();
            }
开发者ID:phaetto,项目名称:services-update,代码行数:20,代码来源:Services.Packages.Security.Security.ModelUserSecureService.cs

示例9: UpdateObject

            public void UpdateObject(ModelUser _ModelUser, string SessionToken)
            {
                if (!ModelUserSecureService.CheckAccessImp(_ModelUser, SessionToken, "Update"))
                throw new UnauthorizedAccessException("Access Denied");

                _ModelUser.Update();
            }
开发者ID:phaetto,项目名称:services-update,代码行数:7,代码来源:Services.Packages.Security.Security.ModelUserSecureService.cs


注:本文中的ModelUser.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。