2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
class ConfirmationsController < Devise::ConfirmationsController
|
2018-11-08 19:23:39 +05:30
|
|
|
include AcceptsPendingInvitations
|
2021-12-11 22:18:48 +05:30
|
|
|
include GitlabRecaptcha
|
2022-01-26 12:08:38 +05:30
|
|
|
include OneTrustCSP
|
2022-08-13 15:12:31 +05:30
|
|
|
include GoogleAnalyticsCSP
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
skip_before_action :required_signup_info
|
2021-12-11 22:18:48 +05:30
|
|
|
prepend_before_action :check_recaptcha, only: :create
|
|
|
|
before_action :load_recaptcha, only: :new
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
feature_category :user_management
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
def almost_there
|
|
|
|
flash[:notice] = nil
|
|
|
|
render layout: "devise_empty"
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
protected
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
def after_resending_confirmation_instructions_path_for(resource)
|
2023-05-27 22:25:52 +05:30
|
|
|
return users_almost_there_path unless Gitlab::CurrentSettings.email_confirmation_setting_soft?
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
stored_location_for(resource) || dashboard_projects_path
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
def after_confirmation_path_for(_resource_name, resource)
|
2018-11-08 19:23:39 +05:30
|
|
|
accept_pending_invitations
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
# incoming resource can either be a :user or an :email
|
|
|
|
if signed_in?(:user)
|
|
|
|
after_sign_in(resource)
|
2015-04-26 12:48:37 +05:30
|
|
|
else
|
2018-03-17 18:26:18 +05:30
|
|
|
Gitlab::AppLogger.info("Email Confirmed: username=#{resource.username} email=#{resource.email} ip=#{request.remote_ip}")
|
2019-07-31 22:56:46 +05:30
|
|
|
flash[:notice] = flash[:notice] + _(" Please sign in.")
|
2023-05-27 22:25:52 +05:30
|
|
|
sign_in_path(resource)
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
def sign_in_path(user)
|
|
|
|
new_session_path(:user, anchor: 'login-pane', invite_email: resource.email)
|
|
|
|
end
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
def check_recaptcha
|
|
|
|
return unless resource_params[:email].present?
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def after_sign_in(resource)
|
|
|
|
after_sign_in_path_for(resource)
|
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
def context_user
|
|
|
|
resource
|
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
ConfirmationsController.prepend_mod_with('ConfirmationsController')
|