Browse Source

PoC

pull/238/head
baarkerlounger 3 years ago
parent
commit
159e24f212
  1. 2
      Gemfile
  2. 4
      Gemfile.lock
  3. 15
      app/mailers/notify_devise_mailer.rb
  4. 3
      config/initializers/devise.rb

2
Gemfile

@ -19,6 +19,8 @@ gem "bootsnap", ">= 1.4.4", require: false
gem "govuk-components"
# GOV UK component form builder DSL
gem "govuk_design_system_formbuilder"
# GOV UK Notify
gem "notifications-ruby-client"
# Turbo and Stimulus
gem "hotwire-rails"
# Soft delete ActiveRecords objects

4
Gemfile.lock

@ -186,6 +186,7 @@ GEM
thor (>= 0.14, < 2.0)
json-schema (2.8.1)
addressable (>= 2.4)
jwt (2.3.0)
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
@ -234,6 +235,8 @@ GEM
racc (~> 1.4)
nokogiri (1.13.1-x86_64-linux)
racc (~> 1.4)
notifications-ruby-client (5.3.0)
jwt (>= 1.5, < 3)
orm_adapter (0.5.0)
overcommit (0.58.0)
childprocess (>= 0.6.3, < 5)
@ -435,6 +438,7 @@ DEPENDENCIES
hotwire-rails
json-schema
listen (~> 3.3)
notifications-ruby-client
overcommit (>= 0.37.0)
pg (~> 1.1)
postcodes_io

15
app/mailers/notify_devise_mailer.rb

@ -0,0 +1,15 @@
class NotifyDeviseMailer < Devise::Mailer
require 'notifications/client'
def reset_password_instructions(record, token, opts = {})
client = ::Notifications::Client.new(ENV["GOVUK_NOTIFY_API_KEY"])
client.send_email(
email_address: record.email,
template_id: "8f1dea41-60e8-4aa2-a23b-f3a751a7438f",
personalisation: {
email: record.email,
link: "#{ENV['host']}/users/password/edit?reset_password_token=#{token}"
}
)
end
end

3
config/initializers/devise.rb

@ -24,10 +24,11 @@ Devise.setup do |config|
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config.mailer_sender = ENV["CORE_EMAIL_USERNAME"]
# config.mailer_sender = ENV["CORE_EMAIL_USERNAME"]
# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
config.mailer = "NotifyDeviseMailer"
# Configure the parent class responsible to send e-mails.
# config.parent_mailer = 'ActionMailer::Base'

Loading…
Cancel
Save