diff --git a/app/controllers/users/confirmations_controller.rb b/app/controllers/users/confirmations_controller.rb index 226f46c5a..3e8f55dea 100644 --- a/app/controllers/users/confirmations_controller.rb +++ b/app/controllers/users/confirmations_controller.rb @@ -30,7 +30,7 @@ def create end # require valid password to confirm email - unless user.valid_password?(confirmation_params[:password]) + unless user.valid_password?(confirmation_params[:password].to_s) flash[:alert] = I18n.t('devise.failure.invalid_password') redirect_to(user_confirmation_path(confirmation_token: confirmation_params[:confirmation_token])) return diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 611e7f9ce..4ac770325 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -28,7 +28,8 @@ def mail(recipient, sender, subject, html, text, attachment = nil) raise(ArgumentError) if html.blank? && text.blank? if ENV['MAILGUN_DOMAIN'].blank? || ENV['MAILGUN_TOKEN'].blank? - Rails.logger.error("mailgun credentials not send, cannot send email") + Rails.logger.error("mailgun credentials not set, cannot send email. Printing email instead.") + Rails.logger.info(html) return end @@ -47,7 +48,8 @@ def mails(recipient, sender, subject, html, text, attachment = nil) raise(ArgumentError) if (html.blank? && text.blank?) || recipient.blank? if ENV['MAILGUN_DOMAIN'].blank? || ENV['MAILGUN_TOKEN'].blank? - Rails.logger.debug("mailgun credentials not send, cannot send email") + Rails.logger.debug("mailgun credentials not set, cannot send email. Printing email instead.") + Rails.logger.info(html) return end diff --git a/app/mailers/mailings/devise.rb b/app/mailers/mailings/devise.rb index 2a77d8e80..3e2e6cca6 100644 --- a/app/mailers/mailings/devise.rb +++ b/app/mailers/mailings/devise.rb @@ -5,35 +5,47 @@ class Devise < ApplicationMailer include ::Devise::Controllers::UrlHelpers def confirmation_instructions(record, token, _opts = {}) - Rails.logger.debug(confirmation_url(record, confirmation_token: token)) if Rails.env.development? + url = confirmation_url(record, confirmation_token: token) + # FIXME: confirmation_url might occassionaly return an url to the activation page. We don't know why + url = url.sub("/activate", "/confirmation") + + if Rails.env.development? + Rails.logger.debug { "Sending confirmation instructions to #{ record.credentials.name } <#{ record.unconfirmed_email }> with activation URL #{ url }" } + end html = render_to_string(locals: { name: record.credentials.name, - confirmation_url: confirmation_url(record, confirmation_token: token), + confirmation_url: url, subject: "#{ I18n.t('association_name') } | #{ I18n.t('mailings.devise.confirmation_instructions.confirm_email') }" }) text = <<~PLAINTEXT #{ I18n.t('mailings.greeting') } #{ record.credentials.name }, - #{ I18n.t('mailings.devise.confirmation_instructions.link_instructions', confirm_link: confirmation_url(record, confirmation_token: token)) } + #{ I18n.t('mailings.devise.confirmation_instructions.link_instructions', confirm_link: url) } #{ I18n.t('mailings.best_regards') } #{ I18n.t('mailings.signature') } PLAINTEXT - return mail(record.unconfirmed_email ||= record.email, nil, I18n.t('mailings.devise.confirmation_instructions.activate_account'), html, text) + mail(record.unconfirmed_email ||= record.email, nil, I18n.t('mailings.devise.confirmation_instructions.activate_account'), html, text) end def activation_instructions(record, token, _opts = {}) url = new_member_confirmation_url(confirmation_token: token) - Rails.logger.debug(url) if Rails.env.development? + # FIXME: confirmation_url might occassionaly return an url to the activation page. We don't know why + url = url.sub("/confirmation", "/activate") + + if Rails.env.development? + Rails.logger.debug { "Sending activation instructions to #{ record.credentials.name } <#{ record.email }> with activation URL #{ url }" } + end html = render_to_string(locals: { name: record.credentials.first_name, activation_url: url, - subject: "#{ I18n.t('mailings.devise.activation_instructions.welcome') } | #{ I18n.t('mailings.devise.confirmation_instructions.activate_account') }" + subject: "#{ I18n.t('mailings.devise.activation_instructions.welcome') } | #{ I18n.t('mailings.devise.confirmation_instructions.activate_account') }", + whatsapp_promo_link: whatsapp_promo_link }) text = <<~MARKDOWN @@ -49,7 +61,9 @@ def activation_instructions(record, token, _opts = {}) instagram_page_link_start: ''.html_safe, linkedin_page_link_start: ''.html_safe, sticky_site_link_start: ''.html_safe, - whatsapp_promo_link_start: ''.html_safe, + # rubocop:disable Rails/OutputSafety + whatsapp_promo_link_start: "".html_safe, + # rubocop:enable Rails/OutputSafety link_end: ''.html_safe) } ## #{ I18n.t('mailings.devise.activation_instructions.corner_stones.education.name') } @@ -66,12 +80,14 @@ def activation_instructions(record, token, _opts = {}) #{ I18n.t('mailings.devise.activation_instructions.corner_stones.sociability.description') } ## #{ I18n.t('mailings.devise.activation_instructions.and_now', url: url) } - #{ I18n.t('mailings.devise.activation_instructions.wrap_up', - #{' '} - url: url, - #{' '} - koala_link_start: ''.html_safe, - link_end: ''.html_safe) } + #{ I18n.t( + 'mailings.devise.activation_instructions.wrap_up_html', + #{' '} + url: url, + #{' '} + koala_link_start: ''.html_safe, + link_end: ''.html_safe + ) } #{ I18n.t('mailings.devise.activation_instructions.account_activation_link', url: url) } @@ -80,7 +96,18 @@ def activation_instructions(record, token, _opts = {}) #{ I18n.t('mailings.signature') } MARKDOWN - return mail(record.email, nil, "#{ I18n.t('mailings.devise.activation_instructions.welcome') } | #{ I18n.t('mailings.devise.confirmation_instructions.activate_account') }", html, text) + mail(record.email, nil, "#{ I18n.t('mailings.devise.activation_instructions.welcome') } | #{ I18n.t('mailings.devise.confirmation_instructions.activate_account') }", html, text) + end + + private + + def whatsapp_promo_link + if I18n.locale == :en + "https://svsticky.nl/promochannel" + else + # Fallback is NL + "https://svsticky.nl/promokanaal" + end end def reset_password_instructions(record, token, _opts = {}) diff --git a/app/views/devise/confirmations/edit.html.haml b/app/views/devise/confirmations/edit.html.haml index 3586149aa..ffaf20694 100644 --- a/app/views/devise/confirmations/edit.html.haml +++ b/app/views/devise/confirmations/edit.html.haml @@ -9,7 +9,7 @@ - if flash[:alert] .alert.alert-danger - %span + %span.dark:text-white = flash[:alert] - if flash[:notice] @@ -18,7 +18,7 @@ = flash[:notice] %fieldset - %h4{:style => "color:white;"} + %h4.dark:text-white = I18n.t :activate, scope: 'devise.confirmations' .form-group @@ -48,7 +48,7 @@ -# i18n todo .row - .text-center + .text-center.dark:text-white = link_to (I18n.t 'devise.registrations.password_recovery'), new_user_password_path | = link_to (I18n.t 'devise.registrations.login'), new_user_session_path diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml index 1b612c737..c14ed858d 100644 --- a/app/views/devise/confirmations/new.html.haml +++ b/app/views/devise/confirmations/new.html.haml @@ -18,7 +18,7 @@ = flash[:notice] %fieldset - %h4= I18n.t 'devise.confirmations.new.instruction' + %h4.dark:text-white= I18n.t 'devise.confirmations.new.instruction' .form-group .input-group-prepend diff --git a/app/views/devise/confirmations/show.html.haml b/app/views/devise/confirmations/show.html.haml index 4374005b0..1a07f2ba5 100644 --- a/app/views/devise/confirmations/show.html.haml +++ b/app/views/devise/confirmations/show.html.haml @@ -18,7 +18,7 @@ = flash[:notice] %fieldset - %h4= I18n.t 'devise.confirmations.new.instruction' + %h4.dark:text-white= I18n.t 'devise.confirmations.new.instruction' .form-group .input-group @@ -39,7 +39,7 @@ = f.submit t('devise.confirmations.new.submit'), :class => 'btn btn-primary btn-block' .row - .text-center + .text-center.dark:text-white = link_to (I18n.t 'devise.registrations.login'), new_user_session_path | = link_to (I18n.t 'devise.registrations.sign_up'), new_registration_path diff --git a/app/views/layouts/doorkeeper.html.haml b/app/views/layouts/doorkeeper.html.haml index e34707538..318f4ebd0 100644 --- a/app/views/layouts/doorkeeper.html.haml +++ b/app/views/layouts/doorkeeper.html.haml @@ -23,8 +23,8 @@ .shadow.px-10.py-4.rounded-md.bg-white.mx-auto.dark:bg-gray-800.dark - - if current_user.present? - %h2.mt-2 + - if current_user.present? and current_user.credentials.first_name? + %h2.mt-2.dark:text-white = I18n.t('layouts.doorkeeper.hi') %b= current_user.credentials.first_name = I18n.t('layouts.doorkeeper.identity_confirmation', name: current_user.credentials.name) diff --git a/app/views/layouts/mailer.html.haml b/app/views/layouts/mailer.html.haml index a2d8f91ba..9f0d43c43 100644 --- a/app/views/layouts/mailer.html.haml +++ b/app/views/layouts/mailer.html.haml @@ -60,7 +60,7 @@ .content{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; max-width: 600px; display: block; margin: 0 auto; padding: 20px;"} %table.main{:bgcolor => "#fff", :cellpadding => "0", :cellspacing => "0", :style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;", :width => "100%"} %tr{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"} - %td.alert.alert-warning{:align => "center", :bgcolor => "#197052", :style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 16px; vertical-align: top; color: #fff; font-weight: 500; text-align: center; border-radius: 3px 3px 0 0; background-color: #197052; margin: 0; padding: 20px;", :valign => "top"} + %td.alert.alert-warning{:align => "center", :bgcolor => "#61518f", :style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 16px; vertical-align: top; color: #fff; font-weight: 500; text-align: center; border-radius: 3px 3px 0 0; background-color: #61518f; margin: 0; padding: 20px;", :valign => "top"} = I18n.t('association_name') %tr{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"} diff --git a/app/views/mailings/devise/activation_instructions.html.haml b/app/views/mailings/devise/activation_instructions.html.haml index 9e3c0a52b..c26dcd3d8 100644 --- a/app/views/mailings/devise/activation_instructions.html.haml +++ b/app/views/mailings/devise/activation_instructions.html.haml @@ -16,10 +16,11 @@ = t('mailings.devise.activation_instructions.about_sticky') = t('mailings.devise.activation_instructions.activity_updates_html', - facebook_group_link_start: raw(""), - facebook_page_link_start: raw(""), - sticky_site_link_start: raw(""), - link_end: raw("")) + instagram_page_link_start: ''.html_safe, + linkedin_page_link_start: ''.html_safe, + sticky_site_link_start: ''.html_safe, + whatsapp_promo_link_start: "".html_safe, + link_end: ''.html_safe) %tr{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"} %td.content-block{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;", :valign => "top"} @@ -32,7 +33,7 @@ %h2 = t('mailings.devise.activation_instructions.corner_stones.business.name') = t('mailings.devise.activation_instructions.corner_stones.business.description_html', - job_offer_page_link_start: raw(''), + job_offer_page_link_start: raw(''), link_end: raw("")) %h2 @@ -41,7 +42,9 @@ %h2 = t('mailings.devise.activation_instructions.and_now') - = t('mailings.devise.activation_instructions.wrap_up') + = t('mailings.devise.activation_instructions.wrap_up_html', + koala_link_start: raw(''), + link_end: raw('')) = t('mailings.devise.activation_instructions.account_activation_instructions') %tr{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"} diff --git a/config/locales/mailings.en.yml b/config/locales/mailings.en.yml index 0d3e481c1..c3a867880 100644 --- a/config/locales/mailings.en.yml +++ b/config/locales/mailings.en.yml @@ -14,7 +14,7 @@ en: account_activation_instructions: Activate your account by clicking the button below account_activation_link: Activate your account for our member system by going to %{url}. activate_account: Activate account - activity_updates_html: 'Do you always want to stay informed about these activities? Follow our %{instagram_page_link_start} Sticky-members Instagram %{link_end} and follow our %{linkedin_page_link_start} our page %{link_end}! Aside from that, you can find all information that you could ever want on our website: %{sticky_site_link_start} svsticky.nl %{link_end}. You can also join our %{whatsapp_promo_link_start} WhatsApp promotion channel %{link_end} to be notified about upcoming activities!' + activity_updates_html: 'Do you always want to stay informed about these activities? Follow us on %{instagram_page_link_start} the Sticky-members Instagram%{link_end} and on %{linkedin_page_link_start} LinkedId%{link_end}! Aside from that, you can find all information that you could ever want on our website: %{sticky_site_link_start} svsticky.nl%{link_end}. You can also join our %{whatsapp_promo_link_start} WhatsApp promotion channel%{link_end} to be notified about upcoming activities!' and_now: And now? corner_stones: business: @@ -29,7 +29,7 @@ en: reception_justification: You are receiving this e-mail, because you signed up for our mighty beautiful study association! At the end of this mail you will find a button to activate your account in our members portal. You could also skip this gorgeous introduction talk en scroll down immediately. We won't see that anyway (or will we?). see_you_soon: See you soon! welcome: Welcome to Sticky! - wrap_up: Curious about which activities we will soon organize? You can find more information in our member portal, %{koala_link_start} Koala%{link_end}, and you can enroll there too! In this member portal you can also edit your profile. + wrap_up_html: Curious about which activities we will soon organize? You can find more information in our member portal, %{koala_link_start} Koala%{link_end}, and you can enroll there too! In this member portal you can also edit your profile. changed_instructions: changed_email: Emailaddress changed inform_change_text: Your emailaddress is changed to %{new_email}. Please contact us as soon as possible (by replying to this email) if this change was not done by you. diff --git a/config/locales/mailings.nl.yml b/config/locales/mailings.nl.yml index 021977bdf..921dc49c1 100644 --- a/config/locales/mailings.nl.yml +++ b/config/locales/mailings.nl.yml @@ -14,7 +14,7 @@ nl: account_activation_instructions: 'Activeer je account door op onderstaande knop te klikken:' account_activation_link: Activeer je account voor ons ledenbeheersysteem door naar %{url} te gaan. activate_account: Activeer account - activity_updates_html: 'Altijd op de hoogte blijven van deze activiteiten? Volg ons op %{instagram_page_link_start} Instagram %{link_end} en volg ons op %{linkedin_page_link_start} LinkedIn %{link_end}! Daarnaast vind je alle informatie die je ooit had kunnen wensen op onze website: %{sticky_site_link_start} svsticky.nl %{link_end}. Je kunt ook lid worden van onze %{whatsapp_promo_link_start} WhatsApp community %{link_end} om altijd op de hoogte gehouden te worden van aankomende activiteiten!' + activity_updates_html: 'Altijd op de hoogte blijven van deze activiteiten? Volg ons op %{instagram_page_link_start} Instagram%{link_end} en op %{linkedin_page_link_start} LinkedIn%{link_end}! Daarnaast vind je alle informatie die je ooit had kunnen wensen op onze website: %{sticky_site_link_start} svsticky.nl%{link_end}. Je kunt ook lid worden van onze %{whatsapp_promo_link_start} WhatsApp community%{link_end} om altijd op de hoogte gehouden te worden van aankomende activiteiten!' and_now: En nu? corner_stones: business: @@ -29,7 +29,7 @@ nl: reception_justification: Je ontvangt deze mail omdat je je hebt aangemeld voor onze machtig mooie studievereniging! Aan het eind van deze mail vind je de knop om je account in ons ledenportaal te activeren. Je kunt ook dit prachtige introductiepraatje overslaan en meteen naar beneden scrollen, dat zien we toch niet (of toch wel?). see_you_soon: Tot snel! welcome: Welkom bij Sticky! - wrap_up: Nieuwsgierig naar welke activiteiten we binnenkort organiseren? Meer informatie vind je in ons ledenportaal, %{koala_link_start} Koala%{link_end}, en je kunt je daar ook meteen inschrijven! Daarnaast kun je in dit ledenportaal ook je gegevens aanpassen. + wrap_up_html: Nieuwsgierig naar welke activiteiten we binnenkort organiseren? Meer informatie vind je in ons ledenportaal, %{koala_link_start} Koala%{link_end}, en je kunt je daar ook meteen inschrijven! Daarnaast kun je in dit ledenportaal ook je gegevens aanpassen. changed_instructions: changed_email: E-mailadres gewijzigd inform_change_text: Je e-mailadres is gewijzigd naar %{new_email}. Neem zo snel mogelijk contact op (door te antwoorden op deze mail) als je deze wijziging niet hebt aangevraagd.