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


C# IAuthenticationManager.SignIn方法代码示例

本文整理汇总了C#中IAuthenticationManager.SignIn方法的典型用法代码示例。如果您正苦于以下问题:C# IAuthenticationManager.SignIn方法的具体用法?C# IAuthenticationManager.SignIn怎么用?C# IAuthenticationManager.SignIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAuthenticationManager的用法示例。


在下文中一共展示了IAuthenticationManager.SignIn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: Login

 public OperationResult<bool> Login(LoginViewModel loginViewModel, IAuthenticationManager authentication)
 {
     var identity = this.loginService.GetUserIndentity(loginViewModel);
     var userIdentity = identity.Result;
     authentication.SignIn(new AuthenticationProperties { IsPersistent = loginViewModel.RememberMe }, userIdentity);
     return new OperationResult<bool>(true);
 }
开发者ID:jstadnicki,项目名称:tbi,代码行数:7,代码来源:LoginLogic.cs

示例3: LoginAsync

 //Аутентификация пользователя
 public async Task<string> LoginAsync(LoginUserModel userLogin, IAuthenticationManager authenticationManager)
 {
     CatalogUser user = await _userManager.FindAsync(userLogin.UserName, userLogin.Password);
     if (user == null)
     {
         return "Неверный логин или пароль";
     }
     else if (user.Activated == false)
     {
         return "Ваша учётная запись ещё не активирована администратором.";
     }
     else
     {
         ClaimsIdentity claim = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
         authenticationManager.SignOut();
         authenticationManager.SignIn(new AuthenticationProperties
         {
             IsPersistent = userLogin.RememberMe,
         }, claim);
         return null;
     }
 }
开发者ID:IvanNkl,项目名称:Catalog,代码行数:23,代码来源:UserService.cs

示例4: SignInAsync

 private async Task SignInAsync(ApplicationUser user, bool isPersistent, IAuthenticationManager authenticationManager)
 {
     authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
     var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
     authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
 }
开发者ID:21428432,项目名称:Basic,代码行数:6,代码来源:LoginBusiness.cs

示例5: SignInAsync

 public static async Task SignInAsync(IAuthenticationManager authManager, ApplicationUserManager userManager,
     User user, bool isPersistent)
 {
     authManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
     authManager.SignIn(new AuthenticationProperties {IsPersistent = isPersistent},
         await user.GenerateUserIdentityAsync(userManager));
 }
开发者ID:alin-rautoiu,项目名称:Cart42,代码行数:7,代码来源:ShoppingCartController.cs

示例6: LoginAsync

 public async Task<string> LoginAsync(UserLogin userLogin, IAuthenticationManager authenticationManager)
 {
     SchoolUser user = await _userManager.FindAsync(userLogin.UserName, userLogin.Password);
     if (user == null)
     {
         return "Неверный логин или пароль";
     }
     else
     {
         ClaimsIdentity claim = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
         authenticationManager.SignOut();
         authenticationManager.SignIn(new AuthenticationProperties
         {
             IsPersistent = userLogin.RememberMe,
         }, claim);
         return null;
     }
 }
开发者ID:IvanNkl,项目名称:AutoSchool,代码行数:18,代码来源:RegisterService.cs

示例7: Authorize

 // Authorize 操作是当你访问任何
 // 受保护的 Web API 时调用的终结点。如果用户未登录,则将被重定向到
 // Login 页。在成功登录后,你可以调用 Web API。
 public void Authorize(IPrincipal User, IAuthenticationManager AuthenticationManager)
 {
     var claims = new ClaimsPrincipal(User).Claims.ToArray();
     var identity = new ClaimsIdentity(claims, "Bearer");
     AuthenticationManager.SignIn(identity);
 }
开发者ID:diycp,项目名称:Magicodes.NET,代码行数:9,代码来源:IdentityStrategy.cs


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