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.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | password_policy-error-on-aggregated-css-files-for-users-forced-to-reset-password-2971743-9.patch | 576 bytes | jrglasgow |
| Capture3_chrome_network.PNG | 44.62 KB | genellann | |
| Capture2_chrome_console.PNG | 43.14 KB | genellann | |
| Capture1_firefox_network.PNG | 57.83 KB | genellann | |
| Capture.PNG | 14.49 KB | genellann |
Issue fork password_policy-2971743
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
Comment #2
genellann commentedI 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.
Comment #3
brian_nsu commentedI 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.
Comment #4
maursilveira commentedI 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.
Comment #5
jrglasgow commentedOne 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.
Comment #6
jrglasgow commentedthinking 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
Comment #7
jrglasgow commentedAs 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.
Comment #9
jrglasgow commentedHere is the patch to add the following to the ignore_routes list
Comment #10
maursilveira commentedI tested the patch from #9 and it works as expected. It applies cleanly and fixes the issue with the aggregated CSS.
Thank you @jrglasgow!
Comment #11
arun.testing3 commentedPatch 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.Comment #12
alastairhoward commentedI'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.
Comment #13
kristen polAssigning to myself as I'm reviewing/merging ready RTBC fixes/updates over the next few days.
Comment #14
kristen polThis doesn't happen on 9.5. Updating steps to reproduce.
Comment #16
kristen polThanks everyone for the help on this issue. The fix has been merged and will be part of the next release.
Comment #20
kristen polAdding credit from duplicate issue:
#3380929: Expired users log in, css and js will not be loaded
Comment #22
stewestThanks! Looking forward to the next release.
Comment #23
kristen polThis is part of the new 4.0.1 release.
Comment #24
stewestJust 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.Comment #25
stewestLooks like it was another module called force_tfa. Sorry!
We had to add
to
$ignore_routes = in_array($route_name, [ ]);