本文整理汇总了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);
}
示例2: HasAllPermissions
public bool HasAllPermissions(IAuthSession session, IAuthRepository authRepo)
{
if (session == null)
return false;
return this.RequiredPermissions.All(x => session.HasPermission(x, authRepo));
}
示例3: HasAllRoles
public bool HasAllRoles(IAuthSession session, IAuthRepository authRepo)
{
if (session == null)
return false;
return this.RequiredRoles.All(x => session.HasRole(x, authRepo));
}
示例4: UserController
public UserController(IAuthRepository authRepository, IAccountService accountService, IDataConverter mapper, IUserService userService, ILogService logService)
: base(mapper)
{
_authRepository = authRepository;
_accountService = accountService;
_userService = userService;
_logService = logService;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
}
示例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>();
}
示例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;
}
示例13: RecipesController
public RecipesController(IMatsMatRepository repository, IAuthRepository authRepo)
:base(repository, authRepo)
{
}
示例14: BoxFilesManager
public BoxFilesManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth)
: base(config, service, converter, auth) { }
示例15: IsAccountLocked
protected virtual bool IsAccountLocked(IAuthRepository authRepo, IUserAuth userAuth, IAuthTokens tokens=null)
{
if (userAuth == null) return false;
return userAuth.LockedDate != null;
}