本文整理汇总了C#中IUserAuthRepository.GetUserAuthByUserName方法的典型用法代码示例。如果您正苦于以下问题:C# IUserAuthRepository.GetUserAuthByUserName方法的具体用法?C# IUserAuthRepository.GetUserAuthByUserName怎么用?C# IUserAuthRepository.GetUserAuthByUserName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserAuthRepository
的用法示例。
在下文中一共展示了IUserAuthRepository.GetUserAuthByUserName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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));
}
示例3: Can_DeleteUserAuth
public void Can_DeleteUserAuth(IUserAuthRepository userAuthRepository)
{
InitTest(userAuthRepository);
var oAuthUserSession = requestContext.ReloadSession();
oAuthUserSession = RegisterAndLogin(userAuthRepository, oAuthUserSession);
var userAuth = userAuthRepository.GetUserAuthByUserName(RegisterDto.UserName);
Assert.That(userAuth, Is.Not.Null);
userAuthRepository.DeleteUserAuth(userAuth.Id.ToString());
userAuth = userAuthRepository.GetUserAuthByUserName(RegisterDto.UserName);
Assert.That(userAuth, Is.Null);
}
示例4: Registering_twice_in_same_session_updates_registration
public void Registering_twice_in_same_session_updates_registration(IUserAuthRepository userAuthRepository)
{
InitTest(userAuthRepository);
var oAuthUserSession = requestContext.ReloadSession();
oAuthUserSession = RegisterAndLogin(userAuthRepository, oAuthUserSession);
var userName1 = RegisterDto.UserName;
var userName2 = "UserName2";
RegisterDto.UserName = userName2;
Register(userAuthRepository, oAuthUserSession, RegisterDto);
var userAuth1 = userAuthRepository.GetUserAuthByUserName(userName1);
var userAuth2 = userAuthRepository.GetUserAuthByUserName(userName2);
Assert.That(userAuth1, Is.Null);
Assert.That(userAuth2, Is.Not.Null);
}
示例5: Registering_twice_creates_two_registrations
public void Registering_twice_creates_two_registrations(IUserAuthRepository userAuthRepository)
{
InitTest(userAuthRepository);
var oAuthUserSession = requestContext.ReloadSession();
RegisterAndLogin(userAuthRepository, oAuthUserSession);
requestContext.RemoveSession();
var userName1 = RegisterDto.UserName;
var userName2 = "UserName2";
RegisterDto.UserName = userName2;
RegisterDto.Email = "[email protected]";
var userAuth1 = userAuthRepository.GetUserAuthByUserName(userName1);
Assert.That(userAuth1, Is.Not.Null);
Register(userAuthRepository, oAuthUserSession, RegisterDto);
userAuth1 = userAuthRepository.GetUserAuthByUserName(userName1);
var userAuth2 = userAuthRepository.GetUserAuthByUserName(userName2);
Assert.That(userAuth1, Is.Not.Null);
Assert.That(userAuth2, Is.Not.Null);
}
示例6: Can_login_with_user_created_CreateUserAuth
public void Can_login_with_user_created_CreateUserAuth(IUserAuthRepository userAuthRepository)
{
((IClearable)userAuthRepository).Clear();
var request = new Registration {
UserName = "UserName",
Password = "[email protected]",
Email = "[email protected]",
DisplayName = "DisplayName",
FirstName = "FirstName",
LastName = "LastName",
};
var loginService = new RegistrationService {
UserAuthRepo = userAuthRepository,
RegistrationValidator = new RegistrationValidator { UserAuthRepo = RegistrationServiceTests.GetStubRepo() },
};
var responseObj = loginService.Post(request);
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, request);
userAuth = userAuthRepository.GetUserAuthByUserName(request.UserName);
AssertEqual(userAuth, request);
userAuth = userAuthRepository.GetUserAuthByUserName(request.Email);
AssertEqual(userAuth, request);
string userId;
var success = userAuthRepository.TryAuthenticate(request.UserName, request.Password, out userId);
Assert.That(success, Is.True);
Assert.That(userId, Is.Not.Null);
success = userAuthRepository.TryAuthenticate(request.Email, request.Password, out userId);
Assert.That(success, Is.True);
Assert.That(userId, Is.Not.Null);
success = userAuthRepository.TryAuthenticate(request.UserName, "Bad Password", out userId);
Assert.That(success, Is.False);
Assert.That(userId, Is.Null);
}
示例7: SeedUsers
private static void SeedUsers(IUserAuthRepository users)
{
//check to see if user exists
if (users.GetUserAuthByUserName("admin.user") == null)
{
//create user
const string pwd = "password";
string hash, salt;
new SaltedHash().GetHashAndSaltString(pwd, out hash, out salt);
users.CreateUserAuth(new UserAuth
{
Id = 1,
DisplayName = "Admin User",
Email = "[email protected]",
UserName = "admin.user",
FirstName = "Admin",
LastName = "User",
PasswordHash = hash,
Salt = salt,
Roles = new List<string> {RoleNames.Admin},
Permissions = new List<string> {"God"}
}, pwd);
}
//check to see if user exists
if (users.GetUserAuthByUserName("joe.budget") == null)
{
//create user
const string pwd = "password";
string hash, salt;
new SaltedHash().GetHashAndSaltString(pwd, out hash, out salt);
users.CreateUserAuth(new UserAuth
{
Id = 1,
DisplayName = "Joe BudgetHolder",
Email = "[email protected]",
UserName = "joe.budget",
FirstName = "Joe",
LastName = "BudgetHolder",
PasswordHash = hash,
Salt = salt,
Roles = new List<string> {"BudgetUser"},
Permissions = new List<string> {"GiveAward"}
}, pwd);
}
//check to see if user exists
if (users.GetUserAuthByUserName("jane.employee") == null)
{
//create user
const string pwd = "password";
string hash, salt;
new SaltedHash().GetHashAndSaltString(pwd, out hash, out salt);
users.CreateUserAuth(new UserAuth
{
Id = 1,
DisplayName = "Jane Employee",
Email = "[email protected]",
UserName = "jane.employee",
FirstName = "Jane",
LastName = "Employee",
PasswordHash = hash,
Salt = salt,
}, pwd);
}
}