private async Task CreateImpl(JoinIdentityUser user, CancellationToken ct = default)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            var hasAnyUser = await UserSet.AnyAsync(ct);

            var dbUser = new DbUser()
            {
                UserName = user.UserName,
                Email    = user.UserName,
                Auth     = new UserAuthDetails()
                {
                    RegisterDate        = DateTime.UtcNow,
                    AspNetSecurityStamp = "",
                },
            };

            if (!hasAnyUser)
            {
                dbUser.Auth.EmailConfirmed = true;
                dbUser.Auth.IsAdmin        = true;
            }

            _ctx.UserSet.Add(dbUser);
            await _ctx.SaveChangesAsync(ct);

            user.Id = dbUser.UserId;
        }
Beispiel #2
0
        public async Task CreateAsync(JoinIdentityUser user)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            var hasAnyUser = await UserSet.AnyAsync();

            var dbUser = new DbUser()
            {
                UserName = user.UserName,
                Email    = user.UserName,
                Auth     = new UserAuthDetails()
                {
                    RegisterDate = DateTime.UtcNow,
                },
            };

            if (!hasAnyUser)
            {
                dbUser.Auth.EmailConfirmed = true;
                dbUser.Auth.IsAdmin        = true;
            }

            _ctx.UserSet.Add(dbUser);
            await _ctx.SaveChangesAsync();

            user.Id = dbUser.UserId;
        }