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


C# IAuthRepository类代码示例

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


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

示例1: SaveUserAuth

        /// <summary>
        /// Saves the Auth Tokens for this request. Called in OnAuthenticated(). 
        /// Overrideable, the default behaviour is to call IUserAuthRepository.CreateOrMergeAuthSession().
        /// </summary>
        protected virtual void SaveUserAuth(IServiceBase authService, IAuthSession session, IAuthRepository authRepo, IAuthTokens tokens)
        {
            if (authRepo == null) return;
            if (tokens != null)
            {
                session.UserAuthId = authRepo.CreateOrMergeAuthSession(session, tokens);
            }

            authRepo.LoadUserAuth(session, tokens);

            foreach (var oAuthToken in session.ProviderOAuthAccess)
            {
                var authProvider = AuthenticateService.GetAuthProvider(oAuthToken.Provider);
                if (authProvider == null) continue;
                var userAuthProvider = authProvider as OAuthProvider;
                if (userAuthProvider != null)
                {
                    userAuthProvider.LoadUserOAuthProvider(session, oAuthToken);
                }
            }

            authRepo.SaveUserAuth(session);

            var httpRes = authService.Request.Response as IHttpResponse;
            if (httpRes != null)
            {
                httpRes.Cookies.AddPermanentCookie(HttpHeaders.XUserAuthId, session.UserAuthId);
            }
            OnSaveUserAuth(authService, session);
        }
开发者ID:JackFong,项目名称:ServiceStack,代码行数:34,代码来源:AuthProvider.cs

示例2: HasAllPermissions

        public bool HasAllPermissions(IAuthSession session, IAuthRepository authRepo)
        {
            if (session == null)
                return false;

            return this.RequiredPermissions.All(x => session.HasPermission(x, authRepo));
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:7,代码来源:RequiredPermissionAttribute.cs

示例3: HasAllRoles

        public bool HasAllRoles(IAuthSession session, IAuthRepository authRepo)
        {
            if (session == null)
                return false;

            return this.RequiredRoles.All(x => session.HasRole(x, authRepo));
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:7,代码来源:RequiredRoleAttribute.cs

示例4: UserController

 public UserController(IAuthRepository authRepository, IAccountService accountService, IDataConverter mapper, IUserService userService, ILogService logService)
     : base(mapper)
 {
     _authRepository = authRepository;
     _accountService = accountService;
     _userService = userService;
     _logService = logService;
 }
开发者ID:iemee,项目名称:AlphaBank,代码行数:8,代码来源:UserController.cs

示例5: StandingsProvider

 public StandingsProvider(IGameRepository gameRepository, IAuthRepository userRepository, ITournamentProvider tournamentProvider)
 {
     if (gameRepository == null) throw new ArgumentNullException(nameof(gameRepository));
     if (userRepository == null) throw new ArgumentNullException(nameof(userRepository));
     if (tournamentProvider == null) throw new ArgumentNullException(nameof(tournamentProvider));
     _gameRepository = gameRepository;
     _userRepository = userRepository;
     _tournamentProvider = tournamentProvider;
 }
开发者ID:Eimovas,项目名称:Tournament.API,代码行数:9,代码来源:StandingsProvider.cs

示例6: HasAllRoles

        public bool HasAllRoles(IHttpRequest req, IAuthSession session, IAuthRepository userAuthRepo=null)
        {
            if (HasAllRoles(session)) return true;

            session.UpdateFromUserAuthRepo(req, userAuthRepo);

            if (HasAllRoles(session))
            {
                req.SaveSession(session);
                return true;
            }
            return false;
        }
开发者ID:qqqzhch,项目名称:ServiceStack,代码行数:13,代码来源:RequiredRoleAttribute.cs

示例7: HasPermission

        public virtual bool HasPermission(string permission, IAuthRepository authRepo)
        {
            if (UserAuthId == null)
                return false;

            if (!FromToken) //If populated from a token it should have the complete list of permissions
            {
                var managesRoles = authRepo as IManageRoles;
                if (managesRoles != null)
                {
                    return managesRoles.HasPermission(this.UserAuthId, permission);
                }
            }

            return this.Permissions != null && this.Permissions.Contains(permission);
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:16,代码来源:AuthUserSession.cs

示例8: HasRole

        public virtual bool HasRole(string role, IAuthRepository authRepo)
        {
            if (UserAuthId == null)
                return false;

            if (!FromToken) //If populated from a token it should have the complete list of roles
            {
                var managesRoles = authRepo as IManageRoles;
                if (managesRoles != null)
                {
                    return managesRoles.HasRole(this.UserAuthId, role);
                }
            }

            return this.Roles != null && this.Roles.Contains(role);
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:16,代码来源:AuthUserSession.cs

示例9: HasAllPermissions

        public bool HasAllPermissions(IRequest req, IAuthSession session, IAuthRepository userAuthRepo=null)
        {
            if (HasAllPermissions(session)) return true;

            if (userAuthRepo == null) 
                userAuthRepo = req.TryResolve<IAuthRepository>();

            if (userAuthRepo == null) return false;

            var userAuth = userAuthRepo.GetUserAuth(session, null);
            session.UpdateSession(userAuth);

            if (HasAllPermissions(session))
            {
                req.SaveSession(session);
                return true;
            }
            return false;
        }
开发者ID:nustack,项目名称:ServiceStack,代码行数:19,代码来源:RequiredPermissionAttribute.cs

示例10: HasAnyPermissions

        public bool HasAnyPermissions(IRequest req, IAuthSession session, IAuthRepository authRepo)
        {
            if (HasAnyPermissions(session, authRepo)) return true;

            if (authRepo == null)
                authRepo = HostContext.AppHost.GetAuthRepository(req);

            if (authRepo == null)
                return false;

            using (authRepo as IDisposable)
            {
                var userAuth = authRepo.GetUserAuth(session, null);
                session.UpdateSession(userAuth);

                if (HasAnyPermissions(session, authRepo))
                {
                    req.SaveSession(session);
                    return true;
                }
                return false;
            }
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:23,代码来源:RequiresAnyPermission.cs

示例11: Startup

 /// <summary>
 /// Initializes a new instance of the <see cref="Startup"/> class.
 /// </summary>
 public Startup()
 {
     this.authRepository = StructuremapMvc.StructureMapDependencyScope.Container.GetInstance<IAuthRepository>();
     this.crmManagerService = StructuremapMvc.StructureMapDependencyScope.Container.GetInstance<ICRMManagerService>();
 }
开发者ID:fishonline,项目名称:API-1,代码行数:8,代码来源:Startup.cs

示例12: ValidateAccount

        protected virtual IHttpResult ValidateAccount(IServiceBase authService, IAuthRepository authRepo, IAuthSession session, IAuthTokens tokens)
        {
            var userAuth = authRepo.GetUserAuth(session, tokens);
            var isLocked = userAuth != null && userAuth.LockedDate != null;

            if (isLocked)
            {
                session.IsAuthenticated = false;
                authService.SaveSession(session, SessionExpiry);
                return authService.Redirect(session.ReferrerUrl.AddHashParam("f", "AccountLocked"));
            }

            return null;
        }
开发者ID:Krave-n,项目名称:ServiceStack,代码行数:14,代码来源:AuthProvider.cs

示例13: RecipesController

 public RecipesController(IMatsMatRepository repository, IAuthRepository authRepo)
     :base(repository, authRepo)
 {
 }
开发者ID:laumsporre,项目名称:matsmat,代码行数:4,代码来源:RecipesController.cs

示例14: BoxFilesManager

 public BoxFilesManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth)
     : base(config, service, converter, auth) { }
开发者ID:Rod-Sychev,项目名称:box-windows-sdk-v2,代码行数:2,代码来源:BoxFilesManager.cs

示例15: IsAccountLocked

 protected virtual bool IsAccountLocked(IAuthRepository authRepo, IUserAuth userAuth, IAuthTokens tokens=null)
 {
     if (userAuth == null) return false;
     return userAuth.LockedDate != null;
 }
开发者ID:dittodhole,项目名称:dotnet-ServiceStack,代码行数:5,代码来源:AuthProvider.cs


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