Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def authenticate_admin_user!

def check_for_first_use
authenticate_user! if User.count == 0 # rubocop:disable Pundit/UsePolicyScope
redirect_to(edit_user_registration_path) if current_user&.reset_password_token == "first_use"
redirect_to(edit_user_registration_path) if current_user&.first_use?
end

def check_scan_status
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def configure_account_update_params
end

def detect_if_first_use
if current_user.reset_password_token == "first_use"
if current_user.first_use?
@first_use = true
devise_parameter_sanitizer.permit(:account_update, keys: [:username])
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def auto_login_single_user
create_admin_user if User.with_role(:administrator).empty?
# If in single user mode, or on first run,
# automatically sign in with an admin account
if !SiteSettings.multiuser_enabled? || User.with_role(:administrator).first.reset_password_token == "first_use"
if !SiteSettings.multiuser_enabled? || User.with_role(:administrator).first.first_use?
sign_in(:user, User.with_role(:administrator).first)
flash.discard
redirect_back_or_to root_path, alert: nil
Expand Down
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def ai_indexable_select_options(object)
end

def tour_attributes(id:, title:, description:)
return {} if current_user&.first_use?
{
"tour-id": id,
"tour-id-completed": current_user&.tour_state&.dig("completed")&.include?(id),
Expand Down
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ def current_space_used
permitted_models.with_permission("own").sum(&:size_on_disk)
end

def first_use?
reset_password_token == "first_use"
end

private

def set_quota
Expand Down
Loading