本文整理汇总了C#中IUserAuthRepository类的典型用法代码示例。如果您正苦于以下问题:C# IUserAuthRepository类的具体用法?C# IUserAuthRepository怎么用?C# IUserAuthRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IUserAuthRepository类属于命名空间,在下文中一共展示了IUserAuthRepository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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, IUserAuthRepository authRepo, IOAuthTokens 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 = AuthService.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.RequestContext.Get<IHttpResponse>();
if (httpRes != null)
{
httpRes.Cookies.AddPermanentCookie(HttpHeaders.XUserAuthId, session.UserAuthId);
}
OnSaveUserAuth(authService, session);
}
开发者ID:yeurch,项目名称:ServiceStack,代码行数:34,代码来源:AuthProvider.cs
示例2: OrderController
public OrderController(IOrderRepository orderRepo,
IUserAuthRepository userAuthRepo,
ICustomerRepository customerRepo,
IOrderLogRepository orderLogRepo,
IOrderItemRepository orderItemRepo,
IInboundPackRepository inboundRepo,
IOutboundRepository outboundRepo,
IOutboundItemRepository outbounditemRepo,
ISectionRepository sectionRepo,
IRMARepository rmaRepo,
IRMALogRepository rmalogRepo,
IRMAItemRepository rmaitemRepo
)
{
_orderRepo = orderRepo;
_userAuthRepo = userAuthRepo;
_customerRepo = customerRepo;
_orderLogRepo = orderLogRepo;
_orderItemRepo = orderItemRepo;
_inboundRepo = inboundRepo;
_outboundRepo = outboundRepo;
_outbounditemRepo = outbounditemRepo;
_sectionRepo = sectionRepo;
_rmaRepo = rmaRepo;
_rmalogRepo = rmalogRepo;
_rmaitemRepo = rmaitemRepo;
}
开发者ID:huayumeng,项目名称:ytoo.service,代码行数:27,代码来源:OrderController.cs
示例3: 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
示例4: Can_AutoLogin_whilst_Registering
public void Can_AutoLogin_whilst_Registering(IUserAuthRepository userAuthRepository)
{
InitTest(userAuthRepository);
var oAuthUserSession = requestContext.ReloadSession();
registrationDto.AutoLogin = true;
Register(userAuthRepository, oAuthUserSession, registrationDto);
oAuthUserSession = requestContext.ReloadSession();
Assert.That(oAuthUserSession.IsAuthenticated, Is.True);
}
开发者ID:nstjelja,项目名称:ServiceStack,代码行数:10,代码来源:OAuthUserSessionTests.cs
示例5: UserAuthController
public UserAuthController(IUserAuthRepository authRepo
,IStoreRepository storeRepo
,IBrandRepository brandRepo
,ICustomerRepository customerRepo)
{
_authRepo = authRepo;
_storeRepo = storeRepo;
_brandRep = brandRepo;
_customerRepo = customerRepo;
}
开发者ID:huayumeng,项目名称:ytoo.service,代码行数:11,代码来源:UserAuthController.cs
示例6: PromotionController
public PromotionController(IPromotionRepository promotionRepository
,IStoreRepository storeRepository
,ITagRepository tagRepository
,IResourceService resourceService
,IUserAuthRepository authRepo)
{
this._promotionRepository = promotionRepository;
_storeRepository = storeRepository;
_tagRepository = tagRepository;
_resourceService = resourceService;
_authRepo = authRepo;
}
开发者ID:huayumeng,项目名称:ytoo.service,代码行数:12,代码来源:PromotionController.cs
示例7: GetRegistrationService
public static RegistrationService GetRegistrationService(
AbstractValidator<Registration> validator = null,
IUserAuthRepository authRepo=null)
{
var requestContext = new MockRequestContext();
var service = new RegistrationService {
RegistrationValidator = validator ?? new RegistrationValidator { UserAuthRepo = GetStubRepo() },
UserAuthRepo = authRepo ?? GetStubRepo(),
RequestContext = requestContext
};
return service;
}
开发者ID:nstjelja,项目名称:ServiceStack,代码行数:12,代码来源:RegistrationServiceTests.cs
示例8: HasAllRoles
public bool HasAllRoles(IHttpRequest req, IAuthSession session, IUserAuthRepository userAuthRepo=null)
{
if (HasAllRoles(session)) return true;
session.UpdateFromUserAuthRepo(req, userAuthRepo);
if (HasAllRoles(session))
{
req.SaveSession(session);
return true;
}
return false;
}
开发者ID:grammarware,项目名称:fodder,代码行数:13,代码来源:src_ServiceStack_ServiceInterface_RequiredRoleAttribute.cs
示例9: ProductController
public ProductController(IProductRepository productRepository
, ISpecialTopicProductRelationRepository specialTopicProductRelationRepository
, IPromotionProductRelationRepository promotionProductRelationRepository
, IStoreRepository storeRepository
, IResourceService resourceService
, IUserAuthRepository userAuthRepo)
{
_productRepository = productRepository;
_stprRepository = specialTopicProductRelationRepository;
_pprRepository = promotionProductRelationRepository;
_storeRepository = storeRepository;
_resourceService = resourceService;
_userAuthRepo = userAuthRepo;
}
开发者ID:huayumeng,项目名称:ytoo.service,代码行数:14,代码来源:ProductController.cs
示例10: OrderController
public OrderController(IOrderRepository orderRepo,
IUserAuthRepository userAuthRepo,
ICustomerRepository customerRepo,
IOrderLogRepository orderLogRepo,
IOrderItemRepository orderItemRepo,
IInboundPackRepository inboundRepo)
{
_orderRepo = orderRepo;
_userAuthRepo = userAuthRepo;
_customerRepo = customerRepo;
_orderLogRepo = orderLogRepo;
_orderItemRepo = orderItemRepo;
_inboundRepo = inboundRepo;
}
开发者ID:huayumeng,项目名称:ytoo.service,代码行数:14,代码来源:OrderController.cs
示例11: ProductPropertyValueController
public ProductPropertyValueController(ITagRepository tagRepo,
ICategoryPropertyRepository tagpropertyRepo,
ICategoryPropertyValueRepository tagpropertyvalRepo,
IProductPropertyValueRepository prodpropertyvalRepo,
IProductPropertyRepository prodpropertyRepo,
IProductRepository prodRepo,
IUserAuthRepository userauthRepo
)
{
_tagRepo = tagRepo;
_tagpropertyRepo = tagpropertyRepo;
_tagpropertyvalueRepo = tagpropertyvalRepo;
_prodpropertyRepo = prodpropertyRepo;
_prodpropertyvalRepo = prodpropertyvalRepo;
_prodRepo = prodRepo;
_userauthRepo = userauthRepo;
}
开发者ID:huayumeng,项目名称:ytoo.service,代码行数:17,代码来源:ProductPropertyValueController.cs
示例12: Connecting_to_facebook_whilst_authenticated_connects_account
public void Connecting_to_facebook_whilst_authenticated_connects_account(IUserAuthRepository userAuthRepository)
{
InitTest(userAuthRepository);
var oAuthUserSession = requestContext.ReloadSession();
oAuthUserSession = RegisterAndLogin(userAuthRepository, oAuthUserSession);
LoginWithFacebook(oAuthUserSession);
var userAuth = userAuthRepository.GetUserAuthByUserName(registrationDto.UserName);
Assert.That(userAuth.UserName, Is.EqualTo(registrationDto.UserName));
var userAuthProviders = userAuthRepository.GetUserOAuthProviders(userAuth.Id.ToString(CultureInfo.InvariantCulture));
Assert.That(userAuthProviders.Count, Is.EqualTo(1));
}
开发者ID:nstjelja,项目名称:ServiceStack,代码行数:17,代码来源:OAuthUserSessionTests.cs
示例13: GetRegistrationService
public static RegistrationService GetRegistrationService(
AbstractValidator<Registration> validator = null,
IUserAuthRepository authRepo=null)
{
var requestContext = new MockRequestContext();
var userAuthRepository = authRepo ?? GetStubRepo();
var service = new RegistrationService {
RegistrationValidator = validator ?? new RegistrationValidator { UserAuthRepo = userAuthRepository },
UserAuthRepo = userAuthRepository,
RequestContext = requestContext,
};
var appHost = GetAppHost();
appHost.Register(userAuthRepository);
service.SetAppHost(appHost);
return service;
}
开发者ID:robertgreen,项目名称:ServiceStack,代码行数:18,代码来源:RegistrationServiceTests.cs
示例14: HasAllRoles
public bool HasAllRoles(IHttpRequest req, IAuthSession session, IUserAuthRepository userAuthRepo=null)
{
if (HasAllRoles(session)) return true;
if (userAuthRepo == null)
userAuthRepo = req.TryResolve<IUserAuthRepository>();
if (userAuthRepo == null) return false;
var userAuth = userAuthRepo.GetUserAuth(session, null);
session.UpdateSession(userAuth);
if (HasAllRoles(session))
{
req.SaveSession(session);
return true;
}
return false;
}
开发者ID:niemyjski,项目名称:ServiceStack,代码行数:19,代码来源:RequiredRoleAttribute.cs
示例15: CreateUser
private void CreateUser(IUserAuthRepository userRep, int id, string userName, string email, string password, List<string> roles = null, List<string> permissions = null)
{
string hash;
string salt;
new SaltedHash().GetHashAndSaltString(password, out hash, out salt);
userRep.CreateUserAuth(new UserAuth {
Id = id,
DisplayName = "DisplayName",
Email = email,
UserName = userName,
FirstName = "FirstName",
LastName = "LastName",
PasswordHash = hash,
Salt = salt,
Roles = roles,
Permissions = permissions
}, password);
}
开发者ID:TIHan,项目名称:MonoWeb,代码行数:19,代码来源:App.cs
示例16: InitTest
protected void InitTest(IUserAuthRepository userAuthRepository)
{
try
{
((IClearable)userAuthRepository).Clear();
}
catch { /*ignore*/ }
var appsettingsMock = new Mock<IAppSettings>();
var appSettings = appsettingsMock.Object;
new AuthFeature(null, new IAuthProvider[] {
new CredentialsAuthProvider(),
new BasicAuthProvider(),
new FacebookAuthProvider(appSettings),
new TwitterAuthProvider(appSettings)
})
.Register(null);
mockService = new Mock<IServiceBase>();
mockService.Expect(x => x.TryResolve<IAuthRepository>()).Returns(userAuthRepository);
requestContext = new BasicRequest
{
Headers = {
{"X-ss-id", SessionExtensions.CreateRandomSessionId() }
}
};
mockService.Expect(x => x.Request).Returns(requestContext);
service = mockService.Object;
RegisterDto = new Register
{
UserName = "UserName",
Password = "[email protected]",
Email = "[email protected]",
DisplayName = "DisplayName",
FirstName = "FirstName",
LastName = "LastName",
};
}
开发者ID:AVee,项目名称:ServiceStack,代码行数:40,代码来源:AuthUserSessionTestsBase.cs
示例17: Can_login_with_user_created_CreateUserAuth
public void Can_login_with_user_created_CreateUserAuth(IUserAuthRepository userAuthRepository)
{
InitTest(userAuthRepository);
var registrationService = GetRegistrationService(userAuthRepository);
var responseObj = registrationService.Post(registrationDto);
var httpResult = responseObj as IHttpResult;
if (httpResult != null)
{
Assert.Fail("HttpResult found: " + httpResult.Dump());
}
var response = (RegistrationResponse)responseObj;
Assert.That(response.UserId, Is.Not.Null);
var userAuth = userAuthRepository.GetUserAuth(response.UserId);
AssertEqual(userAuth, registrationDto);
userAuth = userAuthRepository.GetUserAuthByUserName(registrationDto.UserName);
AssertEqual(userAuth, registrationDto);
userAuth = userAuthRepository.GetUserAuthByUserName(registrationDto.Email);
AssertEqual(userAuth, registrationDto);
UserAuth userId;
var success = userAuthRepository.TryAuthenticate(registrationDto.UserName, registrationDto.Password, out userId);
Assert.That(success, Is.True);
Assert.That(userId, Is.Not.Null);
success = userAuthRepository.TryAuthenticate(registrationDto.Email, registrationDto.Password, out userId);
Assert.That(success, Is.True);
Assert.That(userId, Is.Not.Null);
success = userAuthRepository.TryAuthenticate(registrationDto.UserName, "Bad Password", out userId);
Assert.That(success, Is.False);
Assert.That(userId, Is.Null);
}
开发者ID:nstjelja,项目名称:ServiceStack,代码行数:39,代码来源:OAuthUserSessionTests.cs
示例18: GetRegistrationService
public static RegisterService GetRegistrationService(
AbstractValidator<Register> validator = null,
IUserAuthRepository authRepo = null,
string contentType = null)
{
var requestContext = new MockRequestContext();
if (contentType != null)
{
requestContext.ResponseContentType = contentType;
}
var userAuthRepository = authRepo ?? GetStubRepo();
var service = new RegisterService
{
RegistrationValidator = validator ?? new RegistrationValidator { UserAuthRepo = userAuthRepository },
AuthRepo = userAuthRepository,
RequestContext = requestContext,
};
HostContext.Container.Register(userAuthRepository);
return service;
}
开发者ID:rjdudley,项目名称:ServiceStack,代码行数:22,代码来源:RegistrationServiceTests.cs
示例19: Does_persist_FacebookOAuth
public void Does_persist_FacebookOAuth(IUserAuthRepository userAuthRepository)
{
InitTest(userAuthRepository);
var serviceTokens = MockAuthHttpGateway.Tokens = facebookGatewayTokens;
var oAuthUserSession = requestContext.ReloadSession();
var authInfo = new Dictionary<string, string> { };
var facebookAuth = GetFacebookAuthProvider();
facebookAuth.OnAuthenticated(service, oAuthUserSession, facebookAuthTokens, authInfo);
oAuthUserSession = requestContext.ReloadSession();
Assert.That(oAuthUserSession.FacebookUserId, Is.EqualTo(serviceTokens.UserId));
Assert.That(oAuthUserSession.UserAuthId, Is.Not.Null);
var userAuth = userAuthRepository.GetUserAuth(oAuthUserSession.UserAuthId);
Assert.That(userAuth.Id.ToString(CultureInfo.InvariantCulture), Is.EqualTo(oAuthUserSession.UserAuthId));
Assert.That(userAuth.DisplayName, Is.EqualTo(serviceTokens.DisplayName));
Assert.That(userAuth.FirstName, Is.EqualTo(serviceTokens.FirstName));
Assert.That(userAuth.LastName, Is.EqualTo(serviceTokens.LastName));
Assert.That(userAuth.PrimaryEmail, Is.EqualTo(serviceTokens.Email));
var authProviders = userAuthRepository.GetUserAuthDetails(oAuthUserSession.UserAuthId);
Assert.That(authProviders.Count, Is.EqualTo(1));
var authProvider = authProviders[0];
Assert.That(authProvider.UserAuthId, Is.EqualTo(userAuth.Id));
Assert.That(authProvider.DisplayName, Is.EqualTo(serviceTokens.DisplayName));
Assert.That(authProvider.FirstName, Is.EqualTo(serviceTokens.FirstName));
Assert.That(authProvider.LastName, Is.EqualTo(serviceTokens.LastName));
Assert.That(authProvider.Email, Is.EqualTo(serviceTokens.Email));
Assert.That(authProvider.RequestToken, Is.Null);
Assert.That(authProvider.RequestTokenSecret, Is.Null);
Assert.That(authProvider.AccessToken, Is.Null);
Assert.That(authProvider.AccessTokenSecret, Is.EqualTo(facebookAuthTokens.AccessTokenSecret));
Console.WriteLine(authProviders.Dump());
}
开发者ID:jrmitch120,项目名称:ServiceStack,代码行数:39,代码来源:OAuthUserSessionTests.cs
示例20: Does_merge_FacebookOAuth_TwitterOAuth
public void Does_merge_FacebookOAuth_TwitterOAuth(IUserAuthRepository userAuthRepository)
{
InitTest(userAuthRepository);
var serviceTokensFb = MockAuthHttpGateway.Tokens = facebookGatewayTokens;
var oAuthUserSession = requestContext.ReloadSession();
var facebookAuth = GetFacebookAuthProvider();
facebookAuth.OnAuthenticated(service, oAuthUserSession, facebookAuthTokens, new Dictionary<string, string>());
oAuthUserSession = requestContext.ReloadSession();
var serviceTokensTw = MockAuthHttpGateway.Tokens = twitterGatewayTokens;
var authInfo = new Dictionary<string, string> {
{"user_id", "133371690876022785"},
{"screen_name", "demisbellot"},
};
var twitterAuth = GetTwitterAuthProvider();
twitterAuth.OnAuthenticated(service, oAuthUserSession, twitterAuthTokens, authInfo);
oAuthUserSession = requestContext.ReloadSession();
Assert.That(oAuthUserSession.TwitterUserId, Is.EqualTo(authInfo["user_id"]));
Assert.That(oAuthUserSession.TwitterScreenName, Is.EqualTo(authInfo["screen_name"]));
var userAuth = userAuthRepository.GetUserAuth(oAuthUserSession.UserAuthId);
Assert.That(userAuth.Id.ToString(CultureInfo.InvariantCulture), Is.EqualTo(oAuthUserSession.UserAuthId));
Assert.That(userAuth.DisplayName, Is.EqualTo(serviceTokensTw.DisplayName));
Assert.That(userAuth.FirstName, Is.EqualTo(serviceTokensFb.FirstName));
Assert.That(userAuth.LastName, Is.EqualTo(serviceTokensFb.LastName));
Assert.That(userAuth.PrimaryEmail, Is.EqualTo(serviceTokensFb.Email));
var authProviders = userAuthRepository.GetUserOAuthProviders(oAuthUserSession.UserAuthId);
Assert.That(authProviders.Count, Is.EqualTo(2));
Console.WriteLine(userAuth.Dump());
Console.WriteLine(authProviders.Dump());
}
开发者ID:jarrodalbert,项目名称:ServiceStack,代码行数:38,代码来源:OAuthUserSessionTests.cs
注:本文中的IUserAuthRepository类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论