本文整理汇总了C#中IAuthenticationManager类的典型用法代码示例。如果您正苦于以下问题:C# IAuthenticationManager类的具体用法?C# IAuthenticationManager怎么用?C# IAuthenticationManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAuthenticationManager类属于命名空间,在下文中一共展示了IAuthenticationManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SignUpUser
public async Task<bool> SignUpUser(SignUpViewModel objSignUpViewModel, IAuthenticationManager authenticationManager)
{
var newuser = new ApplicationUser()
{
//Id = objRegisterModel.UserName,
UserName = objSignUpViewModel.UserName,
Email = objSignUpViewModel.EmailAddress,
Password = objSignUpViewModel.Password,
SecurityQuestion = objSignUpViewModel.SecurityQuestion,
SecurityAnswer = objSignUpViewModel.SecurityAnswer,
LastName = objSignUpViewModel.LastName,
FirstName = objSignUpViewModel.FirstName,
Cellphone = objSignUpViewModel.Cell
};
var result = await UserManager.CreateAsync(
newuser, objSignUpViewModel.Password);
if (result.Succeeded)
{
await SignInAsync(newuser, false, authenticationManager);
return true;
}
return false;
}
示例2: AccountController
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, IAuthenticationManager authenticationManager, IInviteRepository inviteRepository)
{
this.userManager = userManager;
this.signInManager = signInManager;
this.authenticationManager = authenticationManager;
this.inviteRepository = inviteRepository;
}
示例3: ChallengeResult
public ChallengeResult(string provider, string redirectUri, string userId, IAuthenticationManager authenticationManager)
{
LoginProvider = provider;
RedirectUri = redirectUri;
UserId = userId;
_authenticationManager = authenticationManager;
}
示例4: IdentityServices
public IdentityServices(DbContext context, IAuthenticationManager authenticationMana, UserStore<IdentityUser> userStor, UserManager<IdentityUser> userMena)
{
db = context;
userStore = userStor;
userMenager = userMena;
authenticationManager = authenticationMana;
userMenager.UserValidator = new UserValidator<IdentityUser>(userMenager) { RequireUniqueEmail = true, AllowOnlyAlphanumericUserNames = false };
userMenager.PasswordValidator = new PasswordValidator() { RequiredLength = 6, RequireLowercase = true, RequireUppercase = true, RequireDigit = true };
signInMenager = new SignInManager<IdentityUser, string>(userMenager, authenticationManager);
userMenager.RegisterTwoFactorProvider("EmailCode", new EmailTokenProvider<IdentityUser>
{
Subject = "Security Code",
BodyFormat = "Your security code is {0}"
});
userMenager.EmailService = new EmailService();
var dataProtectionProvider = Startup.dataProtectionProvider;
if (dataProtectionProvider != null)
{
IDataProtector dataProtector = dataProtectionProvider.Create("ASP.NET Identity");
userMenager.UserTokenProvider = new DataProtectorTokenProvider<IdentityUser>(dataProtector);
}
}
示例5: UserManagerService
public UserManagerService(UserManager<AppIdentityUser> userMenager, IAuthenticationManager authenticationManager, RoleManager<IdentityRole> roleManager)
{
this._userMenager = userMenager;
this._authenticationManager = authenticationManager;
this._roleManager = roleManager;
//Pasword validation rules
_userMenager.UserValidator = new UserValidator<AppIdentityUser>(userMenager) { RequireUniqueEmail = true, AllowOnlyAlphanumericUserNames = false };
_userMenager.PasswordValidator = new PasswordValidator() { RequiredLength = 6, RequireLowercase = true, RequireUppercase = true, RequireDigit = true };
_signInMenager = new SignInManager<AppIdentityUser, string>(_userMenager, _authenticationManager);
//_userMenager.UserLockoutEnabledByDefault = true;
//_userMenager.DefaultAccountLockoutTimeSpan = TimeSpan.FromDays(int.MaxValue);
//_userMenager.SetLockoutEnabled(user.Id, enabled) // Enables or disables lockout for a user
//Register e-mail service for identity
_userMenager.EmailService = new EmailService();
//Token provider for password reset
var dataProtectionProvider = Startup.dataProtectionProvider;
if (dataProtectionProvider != null)
{
IDataProtector dataProtector = dataProtectionProvider.Create("ASP.NET Identity");
userMenager.UserTokenProvider = new DataProtectorTokenProvider<AppIdentityUser>(dataProtector);
}
}
示例6: AuthModule
public AuthModule(IConfiguration configuration, IAuthenticationManager authenticationManager, ITokenizer tokenizer)
: base("auth")
{
Get["/setup"] = _ => string.IsNullOrEmpty(configuration.UserName);
Post["/login"] = _ =>
{
var loginParameters = this.Bind<LoginParameters>();
if (string.IsNullOrEmpty(configuration.UserName))
{
SetAuth(configuration, loginParameters);
}
if (!authenticationManager.IsValid(loginParameters.UserName, loginParameters.Password))
{
return HttpStatusCode.Unauthorized;
}
var identity = new UserIdentity(loginParameters.UserName, null);
var token = tokenizer.Tokenize(identity, Context);
return new
{
Token = token
};
};
}
示例7: AccountController
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, IAuthenticationManager authenticationManager, ApplicationRoleManager roleManager)
{
this.userManager = userManager;
this.signInManager = signInManager;
this.authenticationManager = authenticationManager;
this.roleManager = roleManager;
}
示例8: UserService
public UserService(UserManager<User, int> userManager, SignInManager<User, int> signinManager
, IAuthenticationManager authManager)
{
_userManager = userManager;
_signinManager = signinManager;
_authManager = authManager;
}
示例9: Login
public LoginResult Login(IAuthenticationManager authenticationManager, string email, string password, bool rememberMe)
{
bool isValid = this._queryDispatcher.Dispatch<bool, ValidateLoginQuery>(new ValidateLoginQuery(email, password, Role.Admin));
if (isValid)
{
Member member = this._queryDispatcher.Dispatch<Member, GetMemberByEmailQuery>(new GetMemberByEmailQuery(email));
var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, member.Guid.ToString()), }, DefaultAuthenticationTypes.ApplicationCookie, ClaimTypes.Name, ClaimTypes.Role);
// if you want roles, just add as many as you want here (for loop maybe?)
identity.AddClaim(new Claim(ClaimTypes.Role, "admin"));
// tell OWIN the identity provider, optional
// identity.AddClaim(new Claim(IdentityProvider, "Simplest Auth"));
authenticationManager.SignIn(new AuthenticationProperties
{
IsPersistent = rememberMe
}, identity);
return LoginResult.Success();
}
return LoginResult.InvalidUsernamePassword();
}
示例10: UserController
//public UserController(IUserService userService)
//{
// _userService = userService;
//}
public UserController(IUserService userService, ApplicationSignInManager signInManager, IRoleService roleService, IAuthenticationManager authenticationManager)
{
_userService = userService;
_signInManager = signInManager;
_roleService = roleService;
_authManager = authenticationManager;
}
示例11: SocialConnectedAuthenticationController
public SocialConnectedAuthenticationController(
IAuthenticationManager authenticationManager,
IConnectUserManager connectUserManager)
{
_authenticationManager = authenticationManager;
_connectUserManager = connectUserManager;
}
开发者ID:herskinduk,项目名称:Usergroup.SocialConnectedMvc,代码行数:7,代码来源:SocialConnectedAuthenticationController.cs
示例12: GetAuthenticationResult
public async Task<ExternalAuthenticationResult> GetAuthenticationResult(IAuthenticationManager authenticationManager)
{
var authResult = await authenticationManager.AuthenticateAsync(ExternalCookieName);
if (authResult == null)
return null;
if (!authResult.Identity.IsAuthenticated)
return null;
var externalIdentity = authResult.Identity;
var providerKeyClaim = externalIdentity.FindFirst(ClaimTypes.NameIdentifier);
var issuer = providerKeyClaim.Issuer;
var providerKey = providerKeyClaim.Value;
var name = externalIdentity.FindFirstValue(ClaimTypes.Name);
var email = externalIdentity.FindFirstValue(ClaimTypes.Email);
if (String.IsNullOrEmpty(issuer))
throw new NullReferenceException("The identity claims contain no issuer.");
if (String.IsNullOrEmpty(providerKey))
throw new NullReferenceException("The identity claims contain no provider key");
var result = new ExternalAuthenticationResult
{
Issuer = issuer,
ProviderKey = providerKey,
Name = name,
Email = email
};
return result;
}
示例13: AccountController
public AccountController(LibUserManager userManager, LibSignInManager signInManager, ILibraryRepository repo, IAuthenticationManager _authentication)
{
UserManager = userManager;
SignInManager = signInManager;
_libraryRepository = repo;
authManager = _authentication;
}
示例14: ManageController
public ManageController(ApplicationSignInManager signinManager, ApplicationUserManager appUserManager, IAuthenticationManager authenticationManager)
: base(appUserManager)
{
AuthenticationManager = authenticationManager;
UserManager = appUserManager;
SignInManager = signinManager;
}
示例15: AccountController
/// <summary>
/// Initializes a new instance of the <see cref="AccountController"/> class.
/// </summary>
/// <param name="userManager">The user manager to use.</param>
/// <param name="signInManager">The sign in manager to use.</param>
/// <param name="urlHelper">The URL helper to use.</param>
/// <param name="authManager">The authentication manager to use.</param>
/// <param name="logService">The logging service to use.</param>
/// <remarks>
/// This overload is used to allow dependency injection for testing.
/// </remarks>
public AccountController(IUserManager userManager, ISignInManager signInManager, UrlHelper urlHelper, IAuthenticationManager authManager = null, ILogService logService = null)
: base(userManager, signInManager)
{
Url = urlHelper ?? Url;
_authManager = authManager;
_logService = logService;
}