Exemple #1
0
        private async Task SignInAsync(AbpUser user, bool isPersistent)
        {
            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
            var identity = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);

            identity.AddClaim(new Claim(AbpClaimTypes.TenantId, "42"));
            AuthenticationManager.SignIn(new AuthenticationProperties {
                IsPersistent = isPersistent
            }, identity);
        }
        private async Task SignInAsync(User user, ClaimsIdentity identity = null, bool rememberMe = false)
        {
            if (identity == null)
            {
                identity = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
            }
            identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName));

            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
            AuthenticationManager.SignIn(new AuthenticationProperties {
                IsPersistent = rememberMe
            }, identity);
        }
Exemple #3
0
        private async Task <AbpLoginResult <TTenant, TUser> > CreateLoginResultAsync(TUser user, TTenant tenant = null)
        {
            if (!user.IsActive)
            {
                return(new AbpLoginResult <TTenant, TUser>(AbpLoginResultType.UserIsNotActive));
            }

            if (await IsEmailConfirmationRequiredForLoginAsync(user.TenantId) && !user.IsEmailConfirmed)
            {
                return(new AbpLoginResult <TTenant, TUser>(AbpLoginResultType.UserEmailIsNotConfirmed));
            }

            user.LastLoginTime = Clock.Now;

            await _userManager.AbpStore.UpdateAsync(user);

            await _unitOfWorkManager.Current.SaveChangesAsync();

            return(new AbpLoginResult <TTenant, TUser>(
                       tenant,
                       user,
                       await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie)
                       ));
        }