2022-06-24 14:39:35 +02:00
|
|
|
class RegistrationsController < Devise::RegistrationsController
|
2022-07-18 10:47:54 +02:00
|
|
|
# Needed to have Current.tenant available in Devise's controllers
|
|
|
|
|
prepend_before_action :load_tenant_data
|
2022-08-05 18:15:17 +02:00
|
|
|
before_action :load_oauths, only: [:new]
|
2024-01-26 17:35:00 +01:00
|
|
|
before_action :set_page_title_new, only: [:new]
|
|
|
|
|
before_action :set_page_title_edit, only: [:edit]
|
2022-07-18 10:47:54 +02:00
|
|
|
|
2022-06-24 14:39:35 +02:00
|
|
|
# Override destroy to soft delete
|
|
|
|
|
def destroy
|
|
|
|
|
resource.status = "deleted"
|
2024-05-21 19:10:18 +02:00
|
|
|
resource.email = "#{SecureRandom.alphanumeric(16)}@deleted.com"
|
2024-04-07 13:19:32 +02:00
|
|
|
resource.full_name = t('defaults.deleted_user_full_name')
|
2024-05-21 19:10:18 +02:00
|
|
|
resource.skip_confirmation
|
2022-06-24 14:39:35 +02:00
|
|
|
resource.save
|
|
|
|
|
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
|
|
|
|
|
set_flash_message :notice, :destroyed
|
|
|
|
|
yield resource if block_given?
|
|
|
|
|
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
|
|
|
|
end
|
2024-01-26 17:35:00 +01:00
|
|
|
|
2024-05-14 17:47:17 +02:00
|
|
|
def send_set_password_instructions
|
|
|
|
|
user = User.find_by_email(params[:email])
|
|
|
|
|
|
|
|
|
|
if user.present?
|
|
|
|
|
user.send_reset_password_instructions
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
render json: { success: true } # always return true, even if user not found
|
|
|
|
|
end
|
|
|
|
|
|
2024-01-26 17:35:00 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def set_page_title_new
|
|
|
|
|
@page_title = t('common.forms.auth.sign_up')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def set_page_title_edit
|
|
|
|
|
@page_title = t('common.forms.auth.profile_settings')
|
|
|
|
|
end
|
2022-06-24 14:39:35 +02:00
|
|
|
end
|