Repo steps:
0. Install Drupal 10.1 and password policy module.
1. Force a password reset for a particular role.
2. Open the user edit form for a user of that role.
3. Notice styles are gone from page. Aggregated css files won't load.
4. Turn off css agg. Cache rebuild.
5. Notice styles are back.
6. Turn css agg back on. Cache rebuild.
7. Notice styles are gone.
8. Reset the user's password.
9. Notice styles are back.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

genrad created an issue. See original summary.

genellann’s picture

I noticed that the css and js files have text/html as their content-type in the headers (instead of text/css and text/javascript) for the user when they are being asked to reset their password. I tried adding css and js mime types in the .htaccess file but that didn't change anything.

brian_nsu’s picture

I ran into this issue on our Drupal 10 site this week. A user updated his password, and after the Admin css would not load. Found this post and followed the steps above, which would temporarily allow the user to display the site correctly. Unfortunately, upon logout and login, the css would again fail to load for that user.

I ended up uninstalling the Password Policy module completely to resolve this issue. We completed our Drupal 9 -> 10 upgrade on Nov. 1, 2023. This is the first account to update its password since the upgrade was released.

maursilveira’s picture

Version: 8.x-3.x-dev » 4.0.0

I ran into the same issue in a Drupal 10 site, when testing this module for the first time (version 4.0.0).

Changing the version to 4.0.0, since version 8.x-3.x-dev works with Drupal 8 and 9, which are not supported anymore.

jrglasgow’s picture

One of the items in the Drupal 10.1.0 changelog

CSS and JavaScript aggregation performance improvements
Instead of the aggregated JS/CSS files being generated when the page is loaded they are (as of Drupal core 10.1.0) generated when they are requested.
A site using Password Policy will force a user to change their password when it has expired... When a user logs in with an expired password the are redirected to their account edit page. My supposition is that when a user with an expired password gets to the account edit page and the styles/script aggregations haven't been recently generated (since the most recent cache clear) their browser tries to request these files but Password Policy is instead causing a redirect to the user's account edit page... this is sent as a text/html page instead of the normal CSS or Javascript mime type... I imagine if you looked at your browser's Developer tools network tab you would see h HTTp status code as a 302 redirect as I am seeing.

jrglasgow’s picture

thinking about this the same probably prevent derivative images from being generated... we should go to the EventSubscriber that is causing the redirect and have it check the path... if the request path is equal to the "public://" path we shouldn't redirect

jrglasgow’s picture

Assigned: Unassigned » jrglasgow

As this problem has come up at work and is at the top of my priority list I am working on this, I expect to have a patch before I finish for the day.

jrglasgow’s picture

Here is the patch to add the following to the ignore_routes list

  • system.css_asset
  • system.js_asset
  • image.style_public
maursilveira’s picture

Status: Needs review » Reviewed & tested by the community

I tested the patch from #9 and it works as expected. It applies cleanly and fixes the issue with the aggregated CSS.

Thank you @jrglasgow!

arun.testing3’s picture

Patch from #9 is working. Earlier this message was displayed in the console and styles were not applied to the page
Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

alastairhoward’s picture

I've applied the patch from #9 and it's working well (thanks @jrglasgow). @arun.testing3 are you saying it is working or it is not?

Could we look to get this patch merged in please? I think we could see this as a critical issue for the module. Thanks everyone.

kristen pol’s picture

Assigned: jrglasgow » kristen pol

Assigning to myself as I'm reviewing/merging ready RTBC fixes/updates over the next few days.

kristen pol’s picture

Issue summary: View changes

This doesn't happen on 9.5. Updating steps to reproduce.

  • a7311d6e committed on 4.0.x
    Issue #2971743: Error on aggregated css files for users forced to reset...
kristen pol’s picture

Assigned: kristen pol » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks everyone for the help on this issue. The fix has been merged and will be part of the next release.

kristen pol’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

stewest’s picture

Thanks! Looking forward to the next release.

kristen pol’s picture

Version: 4.0.0 » 4.0.x-dev

This is part of the new 4.0.1 release.

stewest’s picture

StatusFileSize
new195.27 KB
new36.41 KB

Just to update here, where the bug has returned. I wonder if this is from TFA then?

I see now another path in the console.

Refused to execute script from '/user/xxx/security/tfa' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

TFA page with no css

stewest’s picture

Looks like it was another module called force_tfa. Sorry!

We had to add

      'system.js_asset',
      'system.css_asset'

to $ignore_routes = in_array($route_name, [ ]);