Problem/Motivation

The following line in opigno_dashboard.module can cause logins to fail:

$default_route = \Drupal::pathValidator()->getUrlIfValid($default_path)->getRouteName();

getUrlIfValid() can return a FALSE if path is missing (e.g. disabled, unpublished, etc.), which can cause getRouteName() to fail. This line is in a login form submit hook. When this code throws an exception, it can prevent logins.

Steps to reproduce

1. Change the path of views.frontpage.page_1 (the front page view) to something else (e.g. /dashboard).
- Optionally, move all Opigno dashboard blocks in Block Layout to that new path.
2. Create a node page or a page_manager page.
3. Set the site homepage to the page created in step 2.
4. Log in and log out like normal.
5. Disable/unpublish the page created in step 2.
6. Try logging in.

Step 6 will throw an error:

Error: Call to a member function getRouteName() on bool in opigno_dashboard_user_login_submit() (line 277 of /var/app/current/web/modules/contrib/opigno_dashboard/opigno_dashboard.module)

Proposed resolution

Apply attached patch.

Remaining tasks

Review and test.

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

fskreuz created an issue. See original summary.

oleksandr.s’s picture

Patch attached to issue description successfully fix the error. The error disappears. But you will be redirect to unexisting page if unpublished/removed node was set as front page. To fix it I would propose the following patch.
So if default uri is not valid
$default_uri = \Drupal::pathValidator()->getUrlIfValid($default_path);
then $route_name will be used as $default_route

$route_name = \Drupal::routeMatch()->getRouteName();
...
...
$default_route = $default_uri ? $default_uri->getRouteName() : $route_name;

And then build url if $route_name equals to $default_route

if ($default_route === $route_name) {
  $url = Url::fromRoute($default_route, [], $params);
}
ricardoamaro’s picture

I have tested patch #2 (https://www.drupal.org/project/opigno_dashboard/issues/3251764#comment-1...) locally, and it is working properly.

ricardoamaro’s picture

Status: Needs review » Reviewed & tested by the community
axelm’s picture

Hi
Thanks for reporting this. We are aware of this issue and it will be fixed in the next Opigno release.

axelm’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
axelm’s picture

Released in Opigno 3.1.0

axelm’s picture

Status: Patch (to be ported) » Fixed
axelm’s picture

Status: Fixed » Closed (fixed)