Exemple #1
0
        public async Task <User> GetByUsernameOrNullAsync(IdentityUser data)
        {
            data.ThrowIfNull(nameof(data));

            var user = await Context.Users
                       .IncludeAllData()
                       .WithUsername(data.UserName)
                       .FirstOrDefaultAsync();

            if (user != null)
            {
                var save = false;
                if (!user.EmailConfirmed && data.EmailConfirmed)
                {
                    user.EmailConfirmed = true;
                    save = true;
                }

                if (user.IdentityId == null)
                {
                    user.IdentityId = data.Id;
                    save            = true;
                }

                if (save)
                {
                    await Context.SaveChangesAsync();
                }
            }

            return(user);
        }
Exemple #2
0
        public UserClaimsProviderMock(IdentityUser user)
        {
            user.ThrowIfNull(nameof(user));
            _mock = new Mock <IUserClaimsProvider>();

            _claims = CreateClaimsPrincipal(user);
            _claims.Add(EmailConfirmedClaim(user.EmailConfirmed));
        }