gitlab-org--gitlab-foss/app/controllers/concerns/confirm_email_warning.rb

26 lines
888 B
Ruby
Raw Normal View History

2019-07-31 14:47:58 +00:00
# frozen_string_literal: true
module ConfirmEmailWarning
extend ActiveSupport::Concern
included do
before_action :set_confirm_warning, if: -> { Feature.enabled?(:soft_email_confirmation) }
2019-07-31 14:47:58 +00:00
end
protected
def set_confirm_warning
return unless current_user
return if current_user.confirmed?
return if peek_request? || json_request? || !request.get?
2019-07-31 14:47:58 +00:00
email = current_user.unconfirmed_email || current_user.email
flash.now[:warning] = _("Please check your email (%{email}) to verify that you own this address and unlock the power of CI/CD. Didn't receive it? %{resend_link}. Wrong email address? %{update_link}.").html_safe % {
2019-07-31 14:47:58 +00:00
email: email,
resend_link: view_context.link_to(_('Resend it'), user_confirmation_path(user: { email: email }), method: :post),
update_link: view_context.link_to(_('Update it'), profile_path)
}
end
end