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


C# IAuthenticationManager类代码示例

本文整理汇总了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;
        }
开发者ID:21428432,项目名称:Basic,代码行数:26,代码来源:SignUpBusiness.cs

示例2: AccountController

 public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, IAuthenticationManager authenticationManager, IInviteRepository inviteRepository)
 {
     this.userManager = userManager;
     this.signInManager = signInManager;
     this.authenticationManager = authenticationManager;
     this.inviteRepository = inviteRepository;
 }
开发者ID:aleor,项目名称:CurrencyTracker,代码行数:7,代码来源:AccountController.cs

示例3: ChallengeResult

 public ChallengeResult(string provider, string redirectUri, string userId, IAuthenticationManager authenticationManager)
 {
     LoginProvider = provider;
     RedirectUri = redirectUri;
     UserId = userId;
     _authenticationManager = authenticationManager;
 }
开发者ID:Agaspher20,项目名称:VkPostAnalyser,代码行数:7,代码来源:ChallengeResult.cs

示例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);
            }
        }
开发者ID:gkudel,项目名称:Testility,代码行数:28,代码来源:IdentityServices.cs

示例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);
            }
        }
开发者ID:BeczkaPGS,项目名称:ForGrzesiekToReview,代码行数:27,代码来源:UserManagerService.cs

示例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
                };
            };
        }
开发者ID:KyulingLee,项目名称:hadouken,代码行数:28,代码来源:AuthModule.cs

示例7: AccountController

 public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, IAuthenticationManager authenticationManager, ApplicationRoleManager roleManager)
 {
     this.userManager = userManager;
     this.signInManager = signInManager;
     this.authenticationManager = authenticationManager;
     this.roleManager = roleManager;
 }
开发者ID:mmoore99,项目名称:IoCIdentitySample,代码行数:7,代码来源:AccountController.cs

示例8: UserService

 public UserService(UserManager<User, int> userManager, SignInManager<User, int> signinManager
     , IAuthenticationManager authManager)
 {
     _userManager = userManager;
     _signinManager = signinManager;
     _authManager = authManager;
 }
开发者ID:stoneflyop1,项目名称:AspNetIdentity-Owin,代码行数:7,代码来源:IUserService.cs

示例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();
        }
开发者ID:Brontsy,项目名称:Vintage-Rabbit,代码行数:25,代码来源:LoginProvider.cs

示例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;
            }
开发者ID:doubletong,项目名称:SIGLabWithEF,代码行数:12,代码来源:UserController.cs

示例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;
		}
开发者ID:andyliyuze,项目名称:POPForums,代码行数:26,代码来源:ExternalAuthentication.cs

示例13: AccountController

 public AccountController(LibUserManager userManager, LibSignInManager signInManager, ILibraryRepository repo, IAuthenticationManager _authentication)
 {
     UserManager = userManager;
     SignInManager = signInManager;
     _libraryRepository = repo;
     authManager = _authentication;
 }
开发者ID:krypton9208,项目名称:OnlineLib,代码行数:7,代码来源:AccountController.cs

示例14: ManageController

 public ManageController(ApplicationSignInManager signinManager, ApplicationUserManager appUserManager, IAuthenticationManager authenticationManager)
     : base(appUserManager)
 {
     AuthenticationManager = authenticationManager;
     UserManager = appUserManager;
     SignInManager = signinManager;
 }
开发者ID:EhrgoHealth,项目名称:CS6440,代码行数:7,代码来源:ManageController.cs

示例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;
 }
开发者ID:trichards57,项目名称:new-bike-tracker,代码行数:18,代码来源:AccountController.cs


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