Merge branch '18225-avoid-full-table-users-count' into 'master'
Check if the Users table has exactly one user limiting the whole set ## What does this MR do? Limit the query set so about a full scan for all the rows on the users table (only scan to records) #18225 See merge request !4492
This commit is contained in:
commit
2f459a03e0
|
@ -40,7 +40,7 @@ class SessionsController < Devise::SessionsController
|
|||
# Handle an "initial setup" state, where there's only one user, it's an admin,
|
||||
# and they require a password change.
|
||||
def check_initial_setup
|
||||
return unless User.count == 1
|
||||
return unless User.limit(2).count == 1 # Count as much 2 to know if we have exactly one
|
||||
|
||||
user = User.admins.last
|
||||
|
||||
|
|
Loading…
Reference in New Issue