Skip to content

Use the user record cached during authentication and cache the effective user. - #3275

Open
drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:authen-cached-user-usage
Open

drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:authen-cached-user-usage

Conversation

@drgrice1

@drgrice1 drgrice1 commented Nov 9, 2026

Copy link
Copy Markdown
Member

Content generators and the login status template fetched the authenticated user's record from the database again even though it is already cached in $c->authen->{user}. Use the cached record instead, and keep it current when the LTI modules or the Options and UserList pages update that user. Since the cached user always exists in Feedback and GatewayQuiz, the checks for a missing user there are removed. Also preserve showOldAnswers when an LTI login updates a user's data.

Validate and cache the effective user during dispatch. The effective user was not validated until the login status template was rendered, and content generators fetched the effective user's record from the database again. Now WeBWorK::dispatch validates the effective user, falls back to the real user if it does not exist, and caches the record in $c->authen->{effective_user}. Use that cached record everywhere instead, and remove the checks for a missing effective user that are no longer needed.

Remove the unused permission level argument from the GatewayQuiz "can" methods. The permission level was fetched from the database and passed to all of the "can" methods, but none of them used it.

…ive user.

Content generators and the login status template fetched the authenticated
user's record from the database again even though it is already cached in
`$c->authen->{user}`.  Use the cached record instead, and keep it current when
the LTI modules or the Options and UserList pages update that user.  Since the
cached user always exists in Feedback and GatewayQuiz, the checks for a missing
user there are removed.  Also preserve `showOldAnswers` when an LTI login
updates a user's data.

Validate and cache the effective user during dispatch.  The effective
user was not validated until the login status template was rendered, and
content generators fetched the effective user's record from the database
again.  Now `WeBWorK::dispatch` validates the effective user, falls back
to the real user if it does not exist, and caches the record in
`$c->authen->{effective_user}`.  Use that cached record everywhere
instead, and remove the checks for a missing effective user that are no
longer needed.

Remove the unused permission level argument from the GatewayQuiz "can"
methods.  The permission level was fetched from the database and passed
to all of the "can" methods, but none of them used it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@drgrice1
drgrice1 force-pushed the authen-cached-user-usage branch from 6cec242 to b2dc132 Compare November 9, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant