You can use a RouteSubscriber
to do that but it will also affect your user edit form and render it with the default site theme since it uses the same route name. The RouteSubscriber can't alter a route based on a query string parameter such as pass-reset-token
yourmodule/yourmodule.services.yml
services:
yourmodule.routesubscriber:
class: Drupal\yourmodule\Routing\YourmoduleRouteSubscriber
tags:
- { name: event_subscriber, priority: 1 }
yourmodule/src/Routing/YourmoduleRouteSubscriber.php
<?php
namespace Drupal\yourmodule\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
/**
* Custom route subscriber.
*/
class YourmoduleRouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
if ($route = $collection->get('entity.user.edit_form')) {
$options = $route->getOptions();
$options['_custom_theme'] = 'yourthemename';
$route->setOptions($options);
}
}
}