コード例 #1
0
        public AuthUser CreateAuthUser(IIdPool idPool, Role pendingRegistrationRole,
                                       string?name, string?email, string?plaintextPassword)
        {
            if (pendingRegistrationRole.Rolename != Role.PENDING_REGISTRATION_ROLENAME)
            {
                throw new ArgumentException("You're supposed to add the pending registration role.",
                                            nameof(pendingRegistrationRole));
            }

            var nextUserId   = new UserId(idPool.NextForUser());
            var username     = new Username(name);
            var passwordHash = PasswordHash.Generate(plaintextPassword, nextUserId, username);

            return(new AuthUser(nextUserId, username, passwordHash, new Email(email), _clock.UtcNow(),
                                new[] { pendingRegistrationRole.Id }));
        }