Files

45 lines
1.3 KiB
Ruby
Raw Permalink Normal View History

2023-05-21 17:59:36 +03:00
# frozen_string_literal: true
class DashboardController < ApplicationController
2023-06-19 21:44:41 +00:00
skip_before_action :authenticate_user!, only: %i[index]
2023-09-17 00:45:57 +03:00
before_action :maybe_redirect_product_url
before_action :maybe_render_landing
2023-12-02 01:50:54 +02:00
before_action :maybe_redirect_mfa_setup
2023-09-17 00:45:57 +03:00
2024-04-03 00:59:25 +03:00
skip_authorization_check
2023-09-22 02:20:38 +03:00
2023-05-21 17:59:36 +03:00
def index
2024-04-03 00:59:25 +03:00
if cookies.permanent[:dashboard_view] == 'submissions'
SubmissionsDashboardController.dispatch(:index, request, response)
2023-09-22 02:20:38 +03:00
else
2024-04-03 00:59:25 +03:00
TemplatesDashboardController.dispatch(:index, request, response)
2023-09-22 02:20:38 +03:00
end
2023-09-17 00:45:57 +03:00
end
private
def maybe_redirect_product_url
return if !Docuseal.multitenant? || signed_in?
redirect_to Docuseal::PRODUCT_URL, allow_other_host: true
end
2023-06-19 21:44:41 +00:00
2023-12-02 01:50:54 +02:00
def maybe_redirect_mfa_setup
return unless signed_in?
return if current_user.otp_required_for_login
return if !current_user.otp_required_for_login && !AccountConfig.exists?(value: true,
account_id: current_user.account_id,
key: AccountConfig::FORCE_MFA)
2024-09-18 19:47:47 +03:00
redirect_to mfa_setup_path, notice: I18n.t('setup_2fa_to_continue')
2023-12-02 01:50:54 +02:00
end
2023-09-17 00:45:57 +03:00
def maybe_render_landing
return if signed_in?
2023-06-28 00:22:34 +03:00
2023-09-17 00:45:57 +03:00
render 'pages/landing'
2023-05-21 17:59:36 +03:00
end
end