diff --git a/.env.example b/.env.example index 9c5d13f5..4bf6b305 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ SECRET_KEY_BASE= IMAP_SERVER= +DEFAULT_FROM= diff --git a/app/controllers/invitadxs_controller.rb b/app/controllers/invitadxs_controller.rb index 3e2854f2..404130d6 100644 --- a/app/controllers/invitadxs_controller.rb +++ b/app/controllers/invitadxs_controller.rb @@ -22,13 +22,14 @@ class InvitadxsController < ApplicationController if @invitadx.save InvitadxMailer.with(site: @site, invitadx: @invitadx).confirmation_required.deliver - redirect_to invitadx_path(@invitadx) + redirect_to site_invitadx_path(@site, @invitadx) else render 'new' end end def show + @site = Site.find(params[:site_id]) @has_cover = true @invitadx = Invitadx.find(params[:id]) end diff --git a/app/mailers/invitadx_mailer.rb b/app/mailers/invitadx_mailer.rb index 45adb104..ee94f5c3 100644 --- a/app/mailers/invitadx_mailer.rb +++ b/app/mailers/invitadx_mailer.rb @@ -2,6 +2,6 @@ class InvitadxMailer < ApplicationMailer def confirmation_required @invitadx = params[:invitadx] @site = params[:site] - mail to: @invitadx.email, subject: t('.subject') + mail from: "#{@site.config.dig('title')} <#{ENV.fetch('DEFAULT_FROM', 'sutty@kefir.red')}>", to: @invitadx.email, subject: t('.subject') end end diff --git a/app/views/invitadxs/show.haml b/app/views/invitadxs/show.haml index 7a01aac8..e1d47288 100644 --- a/app/views/invitadxs/show.haml +++ b/app/views/invitadxs/show.haml @@ -1,3 +1,4 @@ .row.align-items-center.justify-content-center.full-height .col-md-6.align-self-center - = t('.confirmation_sent') + .alert{role: 'alert', class: "alert-success"} + = t('.confirmation_sent') diff --git a/config/environments/production.rb b/config/environments/production.rb index 5d3ad7d3..7474a055 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -90,7 +90,7 @@ Rails.application.configure do config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :sendmail - config.action_mailer.default_options = { from: 'sutty@kefir.red' } + config.action_mailer.default_options = { from: ENV.fetch('DEFAULT_FROM', 'sutty@kefir.red') } config.middleware.use ExceptionNotification::Rack, email: { diff --git a/config/locales/en.yml b/config/locales/en.yml index 1b45dd3c..e83da363 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -15,6 +15,11 @@ en: reorder: "We're sorry, we couldn't reorder the articles" disordered: "The posts are disordered, this will prevent you from reordering them!" disordered_button: 'Reorder!' + invitadx_mailer: + confirmation_required: + subject: "Confirm your e-mail address" + hi: "Hi!" + body: "Please open this link to confirm your e-mail address." invitadxs: index: title: Guests @@ -25,6 +30,8 @@ en: submit: Register confirmation: confirmed: 'Your account is confirmed, please log in to continue' + show: + confirmation_sent: "We've sent a confirmation link to your e-mail address. Please open that link to continue." info: posts: reorder: "The articles have been reordered!" diff --git a/config/locales/es.yml b/config/locales/es.yml index 859a1131..8bde2fb2 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -15,6 +15,11 @@ es: reorder: "Lo sentimos, no pudimos reordenar los artículos." disordered: 'Los artículos no tienen número de orden, esto impedirá que los puedas reordenar' disordered_button: '¡Reordenar!' + invitadx_mailer: + confirmation_required: + subject: "Confirma tu dirección de correo" + hi: "¡Hola!" + body: "Por favor abre esta dirección para confirmar tu cuenta de correo." invitadxs: index: title: Invitadxs @@ -25,6 +30,8 @@ es: submit: Registrarme confirmation: confirmed: 'Tu cuenta está confirmada, ahora puedes ingresar' + show: + confirmation_sent: "Te hemos enviado un correo de confirmación a tu casilla, por favor confirma tu cuenta antes de continuar." info: posts: reorder: "¡Los artículos fueron reordenados!" diff --git a/config/routes.rb b/config/routes.rb index 3c9b784f..1ba035f4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,13 +9,14 @@ Rails.application.routes.draw do get '/sites/:site_id/public/:type/:basename', to: 'sites#send_public_file' - resources :invitadxs, only: [:create, :show] do - end + # XXX Mantenemos solo esta ruta acá porque form_for no reconoce @site + # como un objeto válido + resources :invitadxs, only: [:create] resources :sites, only: [:index, :show], constraints: { site_id: /[^\/]+/, id: /[^\/]+/ } do resources :posts resources :templates - resources :invitadxs, only: [:index, :new] do + resources :invitadxs, only: [:index, :new, :show] do get :confirmation, to: 'invitadxs#confirmation' end get :'invitadxs/login/new', to: 'login#new'