You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our current implementation of theming allows the currentUser service to dynamically load a sprinkle based on the users.theme column in the database. Since theme sprinkles can potentially contain assets, the assets service is overridden to force the currentUser service to boot up on every request.
This created a potential performance issue in that the database had to be queried for every request - including requests for raw assets. To solve this, the current user object is now automatically cached on disk (or in redis) for a period of time (522f99e).
This caching is done in the Authenticator:: validateUserAccount method. However this does not account for any custom implementations outside of the Authenticator class. For example, I override the currentUser service to dynamically load a user subtype model depending on the value of a user type column. This causes the database to be hit via the currentUser service, which is forced to boot by the assets service.
I actually don't even use the theming feature, so one possibility would be to simply disable theming somehow so that assets doesn't need to boot currentUser. Or, I could have the ability to define my own custom Authenticator class that caches my subtype model along with the original user model. This is not possible at the moment because there are a few hard dependencies on the Authenticator class instead of depending on an interface.
My final option is to check the request path in my currentUser model and skip loading the subtype model if the request is for a raw asset. This seems rather kludgy though.
Does it really make sense to implement per-user themes on the sprinkle level at all? Also, we should remove the hard dependencies on Authenticator and replace with an interface.
The text was updated successfully, but these errors were encountered:
Maybe we can deprecate sprinkle-based theming, with a config setting to disable it in the meantime? I'm not really sure that there is any reason to conditionally load assets/templates/whatever based on the current user. I've found it more tractable to add logic within specific endpoints when I need the interface to vary substantially from user to user.
I guess there is an argument for using themes to implement access control to images, for example, but this can just as easily be done with a custom endpoint.
On top of this, we should use an AuthenticatorInterface so that one could swap in their own custom authenticator class (and do more caching if they want).
And considering the inevitable switch to a separate frontend system like vue or React in the future, per user theme on the server side will probably be obsolete anyway.
lcharette
changed the title
Theming, currentUser, and the assets service
Theming, currentUser, and the assets service (deprecate per user theme)
Apr 29, 2021
Our current implementation of theming allows the
currentUser
service to dynamically load a sprinkle based on theusers.theme
column in the database. Since theme sprinkles can potentially contain assets, theassets
service is overridden to force thecurrentUser
service to boot up on every request.This created a potential performance issue in that the database had to be queried for every request - including requests for raw assets. To solve this, the current user object is now automatically cached on disk (or in redis) for a period of time (522f99e).
This caching is done in the
Authenticator:: validateUserAccount
method. However this does not account for any custom implementations outside of theAuthenticator
class. For example, I override thecurrentUser
service to dynamically load a user subtype model depending on the value of a user type column. This causes the database to be hit via thecurrentUser
service, which is forced to boot by theassets
service.I actually don't even use the theming feature, so one possibility would be to simply disable theming somehow so that
assets
doesn't need to bootcurrentUser
. Or, I could have the ability to define my own customAuthenticator
class that caches my subtype model along with the original user model. This is not possible at the moment because there are a few hard dependencies on theAuthenticator
class instead of depending on an interface.My final option is to check the request path in my
currentUser
model and skip loading the subtype model if the request is for a raw asset. This seems rather kludgy though.Does it really make sense to implement per-user themes on the sprinkle level at all? Also, we should remove the hard dependencies on
Authenticator
and replace with an interface.The text was updated successfully, but these errors were encountered: