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