[X] Did you check to see if this issue already exists?
[X] Is this only a single bug? Do not put multiple bugs in one issue.
[X] Do you agree to follow the rules in our Code of Conduct?
[X] Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.
Summary
When switching between registration modes, pending applications end up in an unexpected state.
This was discovered while working on test cases in #4923.
Solutions to this might include a database migration to address existing cases with inconsistent applications, although in practice this number should be zero for most instances.
It would probably make sense to flip the logic around to always set local_user.accepted_application to true on user creation unless applications are required, and when turning the application requirement off to update not only all local_users, but also update all pending registration_applications admin_ids with the admin disabling the application requirement.
This could also simplify the check on login to not check registration type anymore but simply check if local_user.accepted_application is true.
Steps to Reproduce
Set site to application required
Sign up new user
User can't login, pending application approval
Set site to open registration
Admins still see existing pending applications despite user being able to login, as the application check only happens during, login
Set site to application required
local_user gets set to application accepted (login allowed)
registration_application stays pending, as other logic derives the acceptance state from an admin id being set (does not affect login)
User is still able to login, yet admins see a pending application
Requirements
Summary
When switching between registration modes, pending applications end up in an unexpected state. This was discovered while working on test cases in #4923.
Solutions to this might include a database migration to address existing cases with inconsistent applications, although in practice this number should be zero for most instances.
It would probably make sense to flip the logic around to always set
local_user.accepted_application
totrue
on user creation unless applications are required, and when turning the application requirement off to update not only alllocal_user
s, but also update all pendingregistration_application
sadmin_id
s with the admin disabling the application requirement.This could also simplify the check on login to not check registration type anymore but simply check if
local_user.accepted_application
istrue
.Steps to Reproduce
local_user
gets set to application accepted (login allowed)registration_application
stays pending, as other logic derives the acceptance state from an admin id being set (does not affect login)Technical Details
Logic to approve users when application state changes from no application required to application required: https://github.com/LemmyNet/lemmy/blob/128e78f7c22279fec27d3213a05b440cb1f8db59/crates/db_schema/src/impls/local_user.rs#L104-L112
Logic for checking pending applications on login: https://github.com/LemmyNet/lemmy/blob/128e78f7c22279fec27d3213a05b440cb1f8db59/crates/api/src/local_user/login.rs#L71-L94
Version
0.19.6-beta.4
Lemmy Instance URL
No response