public function changeUsername(User $user, string $newUsername): AuthenticationRecordInterface
    {
        /** @var AuthenticationRecordInterface $auth */
        $auth = $this->authenticationProvider->findByUserId($user->getId());

        if (!$auth) {
            throw new NoSuchUserException();
        }

        // check to see if already taken
        if ($otherAuth = $this->authenticationProvider->findByUsername($newUsername)) {
            if ($auth == $otherAuth) {
                return $auth;
            } else {
                throw new UsernameTakenException();
            }
        }

        $auth->setUsername($newUsername);
        $this->authenticationProvider->update($auth);

        return $auth;
    }