Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboarding updates #1121

Merged
merged 7 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/users/confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
55 changes: 41 additions & 14 deletions app/mailers/mailings/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,7 +61,9 @@ def activation_instructions(record, token, _opts = {})
instagram_page_link_start: '<a href="https://www.instagram.com/stickyutrecht/">'.html_safe,
linkedin_page_link_start: '<a href="https://www.linkedin.com/company/studievereniging-sticky">'.html_safe,
sticky_site_link_start: '<a href="https://svsticky.nl">'.html_safe,
whatsapp_promo_link_start: '<a href="https://svsticky.nl/promokanaal">'.html_safe,
# rubocop:disable Rails/OutputSafety
whatsapp_promo_link_start: "<a href=\"#{ whatsapp_promo_link }\">".html_safe,
# rubocop:enable Rails/OutputSafety
link_end: '</a>'.html_safe) }

## #{ I18n.t('mailings.devise.activation_instructions.corner_stones.education.name') }
Expand All @@ -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: '<a href="https://koala.svsticky.nl/">'.html_safe,
link_end: '</a>'.html_safe) }
#{ I18n.t(
'mailings.devise.activation_instructions.wrap_up_html',
#{' '}
url: url,
#{' '}
koala_link_start: '<a href="https://koala.svsticky.nl/">'.html_safe,
link_end: '</a>'.html_safe
) }

#{ I18n.t('mailings.devise.activation_instructions.account_activation_link', url: url) }

Expand All @@ -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 = {})
Expand Down
6 changes: 3 additions & 3 deletions app/views/devise/confirmations/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

- if flash[:alert]
.alert.alert-danger
%span
%span.dark:text-white
= flash[:alert]

- if flash[:notice]
Expand All @@ -18,7 +18,7 @@
= flash[:notice]

%fieldset
%h4{:style => "color:white;"}
%h4.dark:text-white
= I18n.t :activate, scope: 'devise.confirmations'

.form-group
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/views/devise/confirmations/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/views/devise/confirmations/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions app/views/layouts/doorkeeper.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/mailer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
SpookyBoy99 marked this conversation as resolved.
Show resolved Hide resolved
= I18n.t('association_name')

%tr{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"}
Expand Down
15 changes: 9 additions & 6 deletions app/views/mailings/devise/activation_instructions.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
= t('mailings.devise.activation_instructions.about_sticky')

= t('mailings.devise.activation_instructions.activity_updates_html',
facebook_group_link_start: raw("<a href=\"https://www.facebook.com/groups/814759978565158\">"),
facebook_page_link_start: raw("<a href=\"https://www.facebook.com/stickyutrecht\">"),
sticky_site_link_start: raw("<a href=\"https://svsticky.nl\">"),
link_end: raw("</a>"))
instagram_page_link_start: '<a href="https://www.instagram.com/stickyutrecht/">'.html_safe,
linkedin_page_link_start: '<a href="https://www.linkedin.com/company/studievereniging-sticky">'.html_safe,
sticky_site_link_start: '<a href="https://svsticky.nl">'.html_safe,
whatsapp_promo_link_start: "<a href=\"#{whatsapp_promo_link}\">".html_safe,
link_end: '</a>'.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"}
Expand All @@ -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('<a href="https://svsticky.nl/partners/vacatures">'),
job_offer_page_link_start: raw('<a href="https://svsticky.nl/carriere/vacatures">'),
link_end: raw("</a>"))

%h2
Expand All @@ -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('<a href="https://koala.svsticky.nl">'),
link_end: raw('</a>'))

= 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;"}
Expand Down
4 changes: 2 additions & 2 deletions config/locales/mailings.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions config/locales/mailings.nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand Down
Loading