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


C# IUserAuth类代码示例

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


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


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