2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-05-23 15:09:22 +02:00
|
|
|
class TargetedUserLinksController < ApplicationController
|
|
|
|
def show
|
2023-12-14 10:10:20 +01:00
|
|
|
erase_user_location!
|
|
|
|
store_user_location! if !user_signed_in?
|
2022-10-04 11:41:32 +02:00
|
|
|
if targeted_user_link.invalid_signed_in_user?(current_user)
|
2022-05-23 15:09:22 +02:00
|
|
|
render
|
|
|
|
else
|
2022-10-04 11:41:32 +02:00
|
|
|
redirect_to targeted_user_link.redirect_url(Rails.application.routes.url_helpers)
|
2022-05-23 15:09:22 +02:00
|
|
|
end
|
2022-10-04 11:41:32 +02:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
redirect_to root_path, flash: { error: t('errors.messages.targeted_user_link_expired') }
|
2022-05-23 15:09:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2023-12-14 10:10:20 +01:00
|
|
|
def store_user_location!
|
|
|
|
store_location_for(:user, request.fullpath)
|
|
|
|
end
|
|
|
|
|
|
|
|
def erase_user_location!
|
|
|
|
clear_stored_location_for(:user)
|
|
|
|
end
|
|
|
|
|
2022-10-04 11:41:32 +02:00
|
|
|
def targeted_user_link
|
|
|
|
@targeted_user_link ||= TargetedUserLink.find(params[:id])
|
2022-05-23 15:09:22 +02:00
|
|
|
end
|
|
|
|
end
|