2019-07-31 10:47:58 -04:00
# frozen_string_literal: true
module ConfirmEmailWarning
extend ActiveSupport :: Concern
included do
2019-12-03 13:06:49 -05:00
before_action :set_confirm_warning , if : :show_confirm_warning?
2019-07-31 10:47:58 -04:00
end
protected
2019-12-03 13:06:49 -05:00
def show_confirm_warning?
2020-03-11 20:09:34 -04:00
html_request? && request . get? && Feature . enabled? ( :soft_email_confirmation )
2019-12-03 13:06:49 -05:00
end
2019-07-31 10:47:58 -04:00
def set_confirm_warning
return unless current_user
return if current_user . confirmed?
email = current_user . unconfirmed_email || current_user . email
2019-11-07 19:05:58 -05:00
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 10:47:58 -04: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