public function dispatcher(\Illuminate\Auth\UserInterface $user = null) { // map the user ID: 1 is guest, otherwise add 100 $vUID = null === $user ? 1 : $user->getKey() + $this->auth_user_offset; // lookup the vanilla user with that ID $vUser = User::find($vUID); // not there, create if (null === $vUser) { if (null === $user) { if (is_callable($this->create_guest_account)) { $vUser = call_user_func($this->create_guest_account); } if (!$vUser instanceof User) { throw new NoVanillaUserMappedToGuest(); } } else { if (is_callable($this->create_account_for)) { $vUser = call_user_func($this->create_account_for, $vUID, $user); } if (!$vUser instanceof User) { throw new NoVanillaUserMappedToUser(); } } // update authenticated user data } else { if (null !== $user && is_callable($this->update_account_for)) { call_user_func($this->update_account_for, $user, $vUser); } } return $vUser; }