• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IUserAuth类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IUserAuth的典型用法代码示例。如果您正苦于以下问题:C# IUserAuth类的具体用法?C# IUserAuth怎么用?C# IUserAuth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IUserAuth类属于命名空间,在下文中一共展示了IUserAuth类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AuditInterceptor

        public AuditInterceptor(IUserAuth userAuth, IRepository<Audit> auditRepository)
        {
            Check.Require(userAuth != null, "User Authorization Context is Required");

            UserAuth = userAuth;
            AuditRepository = auditRepository;
        }
开发者ID:ucdavis,项目名称:FSNEP,代码行数:7,代码来源:AuditInterceptor.cs


示例2: GetPermissions

 public static ICollection<string> GetPermissions(this IAuthRepository UserAuthRepo, IUserAuth userAuth)
 {
     var managesRoles = UserAuthRepo as IManageRoles;
     return managesRoles != null 
         ? managesRoles.GetPermissions(userAuth.Id.ToString()) 
         : userAuth.Permissions;
 }
开发者ID:AVee,项目名称:ServiceStack,代码行数:7,代码来源:UserAuthRepositoryExtensions.cs


示例3: CreateUserAuth

        public IUserAuth CreateUserAuth(IUserAuth newUser, string password)
        {
            ValidateNewUser(newUser, password);

            AssertNoExistingUser(newUser);

            var saltedHash = new SaltedHash();
            string salt;
            string hash;
            saltedHash.GetHashAndSaltString(password, out hash, out salt);
            var digestHelper = new DigestAuthFunctions();
            newUser.DigestHa1Hash = digestHelper.CreateHa1(newUser.UserName, DigestAuthProvider.Realm, password);
            newUser.PasswordHash = hash;
            newUser.Salt = salt;
            newUser.CreatedDate = DateTime.UtcNow;
            newUser.ModifiedDate = newUser.CreatedDate;

            using (var session = _documentStore.OpenSession())
            {
                session.Store(newUser);
                session.SaveChanges();
            }

            return newUser;
        }
开发者ID:GDBSD,项目名称:ServiceStack,代码行数:25,代码来源:RavenDbUserAuthRepository.cs


示例4: AssignRoles

        /// <summary>
        /// Creates the required missing tables or DB schema 
        /// </summary>
        public static void AssignRoles(this IAuthRepository UserAuthRepo, IUserAuth userAuth,
            ICollection<string> roles = null, ICollection<string> permissions = null)
        {
            var managesRoles = UserAuthRepo as IManageRoles;
            if (managesRoles != null)
            {
                managesRoles.AssignRoles(userAuth.Id.ToString(), roles, permissions);
            }
            else
            {
                if (!roles.IsEmpty())
                {
                    foreach (var missingRole in roles.Where(x => !userAuth.Roles.Contains(x)))
                    {
                        userAuth.Roles.Add(missingRole);
                    }
                }

                if (!permissions.IsEmpty())
                {
                    foreach (var missingPermission in permissions.Where(x => !userAuth.Permissions.Contains(x)))
                    {
                        userAuth.Permissions.Add(missingPermission);
                    }
                }

                UserAuthRepo.SaveUserAuth(userAuth);
            }
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:32,代码来源:UserAuthRepositoryExtensions.cs


示例5: CreateUser

 private static void CreateUser(IUserAuthRepository userRepo, IUserAuth user, string password)
 {
     string hash;
     string salt;
     new SaltedHash().GetHashAndSaltString(password, out hash, out salt);
     user.Salt = salt;
     user.PasswordHash = hash;
     userRepo.CreateUserAuth(user, password);
 }
开发者ID:ryandavidhartman,项目名称:Auth202,代码行数:9,代码来源:DataBaseHelper.cs


示例6: PopulateSession

        public static void PopulateSession(this IAuthSession session, IUserAuth userAuth, List<IAuthTokens> authTokens)
        {
            if (userAuth == null)
                return;

            var originalId = session.Id;
            session.PopulateWith(userAuth);
            session.Id = originalId;
            session.UserAuthId = userAuth.Id.ToString(CultureInfo.InvariantCulture);
            session.ProviderOAuthAccess = authTokens;
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:11,代码来源:UserAuthRepositoryExtensions.cs


示例7: GetRoles

 public static ICollection<string> GetRoles(this IAuthRepository UserAuthRepo, IUserAuth userAuth)
 {
     var managesRoles = UserAuthRepo as IManageRoles;
     if (managesRoles != null)
     {
         return managesRoles.GetRoles(userAuth.Id.ToString());
     }
     else
     {
         return userAuth.Roles;
     }
 }
开发者ID:nicpitsch,项目名称:ServiceStack,代码行数:12,代码来源:UserAuthRepositoryExtensions.cs


示例8: ValidateNewUserWithoutPassword

        private void ValidateNewUserWithoutPassword(IUserAuth newUser)
        {
            newUser.ThrowIfNull("newUser");

            if (newUser.UserName.IsNullOrEmpty() && newUser.Email.IsNullOrEmpty())
                throw new ArgumentNullException("UserName or Email is required");

            if (!newUser.UserName.IsNullOrEmpty())
            {
                if (!ValidUserNameRegEx.IsMatch(newUser.UserName))
                    throw new ArgumentException("UserName contains invalid characters", "UserName");
            }
        }
开发者ID:GDBSD,项目名称:ServiceStack,代码行数:13,代码来源:RavenDbUserAuthRepository.cs


示例9: AssertNoExistingUser

 private void AssertNoExistingUser(IUserAuth newUser, IUserAuth exceptForExistingUser = null)
 {
     if (newUser.UserName != null)
     {
         var existingUser = GetUserAuthByUserName(newUser.UserName);
         if (existingUser != null
             && (exceptForExistingUser == null || existingUser.Id != exceptForExistingUser.Id))
             throw new ArgumentException("User {0} already exists".Fmt(newUser.UserName));
     }
     if (newUser.Email != null)
     {
         var existingUser = GetUserAuthByUserName(newUser.Email);
         if (existingUser != null
             && (exceptForExistingUser == null || existingUser.Id != exceptForExistingUser.Id))
             throw new ArgumentException("Email {0} already exists".Fmt(newUser.Email));
     }
 }
开发者ID:GDBSD,项目名称:ServiceStack,代码行数:17,代码来源:RavenDbUserAuthRepository.cs


示例10: Setup

        public void Setup()
        {
            _userBLL = MockRepository.GenerateStub<IUserBLL>();
            _userAuth = MockRepository.GenerateStub<IUserAuth>();
            _delegateBLL = new DelegateBLL(_userAuth, _userBLL);
            _roleProvider = MockRepository.GenerateStub<RoleProvider>();
            _userAuth.RoleProvider = _roleProvider;

            _currentUser.UserName = "_currentUser";
            _userBLL.Expect(a => a.GetUser()).Return(_currentUser).Repeat.Any();

            for (int i = 0; i < 3; i++)
            {
                _users.Add(CreateValidEntities.User(i+3));
                //_users[i].Delegate = _users[0];
            }
        }
开发者ID:ucdavis,项目名称:FSNEP,代码行数:17,代码来源:DelegateBLLTests.cs


示例11: TryAuthenticate

        public bool TryAuthenticate(string userName, string password, out IUserAuth userAuth)
        {
            userAuth = GetUserAuthByUserName(userName);
            if (userAuth == null)
                return false;

            if (HostContext.Resolve<IHashProvider>().VerifyHashString(password, userAuth.PasswordHash, userAuth.Salt))
            {
                this.RecordSuccessfulLogin(userAuth);

                return true;
            }

            this.RecordInvalidLoginAttempt(userAuth);

            userAuth = null;
            return false;
        }
开发者ID:rudygt,项目名称:ServiceStack,代码行数:18,代码来源:NHibernateUserAuthRepository.cs


示例12: CreateUserAuth

        public IUserAuth CreateUserAuth(IUserAuth newUser, string password)
        {
            ValidateNewUser(newUser, password);

            AssertNoExistingUser(newUser);

            var saltedHash = new SaltedHash();
            string salt;
            string hash;
            saltedHash.GetHashAndSaltString(password, out hash, out salt);

            newUser.PasswordHash = hash;
            newUser.Salt = salt;
            newUser.CreatedDate = DateTime.UtcNow;
            newUser.ModifiedDate = newUser.CreatedDate;

            Session.Save(new UserAuthNHibernate(newUser));
            return newUser;
        }
开发者ID:GloomHu,项目名称:bucket,代码行数:19,代码来源:NHibernateUserAuthRepository.cs


示例13: UnAssignRoles

        public static void UnAssignRoles(this IAuthRepository UserAuthRepo, IUserAuth userAuth,
            ICollection<string> roles = null, ICollection<string> permissions = null)
        {
            var managesRoles = UserAuthRepo as IManageRoles;
            if (managesRoles != null)
            {
                managesRoles.UnAssignRoles(userAuth.Id.ToString(), roles, permissions);
            }
            else
            {
                roles.Each(x => userAuth.Roles.Remove(x));
                permissions.Each(x => userAuth.Permissions.Remove(x));

                if (roles != null || permissions != null)
                {
                    UserAuthRepo.SaveUserAuth(userAuth);
                }
            }
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:19,代码来源:UserAuthRepositoryExtensions.cs


示例14: CreateUserAuth

        public IUserAuth CreateUserAuth(IUserAuth newUser, string password)
        {
            UserEntry user = newUser as UserEntry;

            ValidateNewUser(user, password);
            AssertNoExistingUser(user);

            var saltedHash = HostContext.Resolve<IHashProvider>();
            string salt;
            string hash;
            saltedHash.GetHashAndSaltString(password, out hash, out salt);

            user.PartitionKey = Guid.NewGuid().ToString();
            user.RowKey = newUser.UserName;
            user.RowKey = TableEntityHelper.RemoveDiacritics(user.RowKey);
            user.RowKey = TableEntityHelper.ToAzureKeyString(user.RowKey);

            //user.Id = 0;
            user.PasswordHash = hash;
            user.Salt = salt;
            var digestHelper = new DigestAuthFunctions();
            user.DigestHa1Hash = digestHelper.CreateHa1(user.UserName, DigestAuthProvider.Realm, password);
            user.CreatedDate = DateTime.UtcNow;
            user.ModifiedDate = user.CreatedDate;

            //var userId = user.Id.ToString(CultureInfo.InvariantCulture);
            //if (!newUser.UserName.IsNullOrEmpty())
            //{
            //    redis.SetEntryInHash(IndexUserNameToUserId, newUser.UserName, userId);
            //}
            //if (!newUser.Email.IsNullOrEmpty())
            //{
            //    redis.SetEntryInHash(IndexEmailToUserId, newUser.Email, userId);
            //}
            SaveUserAuth(user);

            return user;
        }
开发者ID:Filimindji,项目名称:YAQAAP,代码行数:38,代码来源:AzureAuthProvider.cs


示例15: CreateUserAuth

        public IUserAuth CreateUserAuth(IUserAuth newUser, string password)
        {
            newUser.ValidateNewUser(password);

            AssertNoExistingUser(mongoDatabase, newUser);

            var saltedHash = HostContext.Resolve<IHashProvider>();
            string salt;
            string hash;
            saltedHash.GetHashAndSaltString(password, out hash, out salt);
            var digestHelper = new DigestAuthFunctions();
            newUser.DigestHa1Hash = digestHelper.CreateHa1(newUser.UserName, DigestAuthProvider.Realm, password);
            newUser.PasswordHash = hash;
            newUser.Salt = salt;
            newUser.CreatedDate = DateTime.UtcNow;
            newUser.ModifiedDate = newUser.CreatedDate;

            SaveUser(newUser);
            return newUser;
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:20,代码来源:MongoDbAuthRepository.cs


示例16: SaveUserAuth

        public void SaveUserAuth(IUserAuth userAuth)
        {
            userAuth.ModifiedDate = DateTime.UtcNow;
            if (userAuth.CreatedDate == default(DateTime))
                userAuth.CreatedDate = userAuth.ModifiedDate;

            SaveUser(userAuth);
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:8,代码来源:MongoDbAuthRepository.cs


示例17: LoadUserAuth

 private void LoadUserAuth(IAuthSession session, IUserAuth userAuth)
 {
     session.PopulateSession(userAuth,
         GetUserAuthDetails(session.UserAuthId).ConvertAll(x => (IAuthTokens)x));
 }
开发者ID:AVee,项目名称:ServiceStack,代码行数:5,代码来源:MongoDbAuthRepository.cs


示例18: TryAuthenticate

        public bool TryAuthenticate(Dictionary<string, string> digestHeaders, string privateKey, int nonceTimeOut, string sequence, out IUserAuth userAuth)
        {
            //userId = null;
            userAuth = GetUserAuthByUserName(digestHeaders["username"]);
            if (userAuth == null)
                return false;

            var digestHelper = new DigestAuthFunctions();
            if (digestHelper.ValidateResponse(digestHeaders, privateKey, nonceTimeOut, userAuth.DigestHa1Hash, sequence))
            {
                this.RecordSuccessfulLogin(userAuth);

                return true;
            }

            this.RecordInvalidLoginAttempt(userAuth);

            userAuth = null;
            return false;
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:20,代码来源:MongoDbAuthRepository.cs


示例19: UpdateUserAuth

        public IUserAuth UpdateUserAuth(IUserAuth existingUser, IUserAuth newUser)
        {
            newUser.ValidateNewUser();

            AssertNoExistingUser(mongoDatabase, newUser);

            newUser.Id = existingUser.Id;
            newUser.PasswordHash = existingUser.PasswordHash;
            newUser.Salt = existingUser.Salt;
            newUser.DigestHa1Hash = existingUser.DigestHa1Hash;
            newUser.CreatedDate = existingUser.CreatedDate;
            newUser.ModifiedDate = DateTime.UtcNow;
            SaveUser(newUser);

            return newUser;
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:16,代码来源:MongoDbAuthRepository.cs


示例20: AssertNoExistingUser

 private static void AssertNoExistingUser(IMongoDatabase mongoDatabase, IUserAuth newUser, IUserAuth exceptForExistingUser = null)
 {
     if (newUser.UserName != null)
     {
         var existingUser = GetUserAuthByUserName(mongoDatabase, newUser.UserName);
         if (existingUser != null
             && (exceptForExistingUser == null || existingUser.Id != exceptForExistingUser.Id))
             throw new ArgumentException(string.Format(ErrorMessages.UserAlreadyExistsTemplate1, newUser.UserName));
     }
     if (newUser.Email != null)
     {
         var existingUser = GetUserAuthByUserName(mongoDatabase, newUser.Email);
         if (existingUser != null
             && (exceptForExistingUser == null || existingUser.Id != exceptForExistingUser.Id))
             throw new ArgumentException(string.Format(ErrorMessages.EmailAlreadyExistsTemplate1, newUser.Email));
     }
 }
开发者ID:AVee,项目名称:ServiceStack,代码行数:17,代码来源:MongoDbAuthRepository.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IUserAuthRepository类代码示例发布时间:2022-05-24
下一篇:
C# IUserAccountService类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap