Skip to content

Commit

Permalink
Merge pull request #10265 from DFE-Digital/567-replace-magic-links-in…
Browse files Browse the repository at this point in the history
…-candidate-emails-with-login-link

[567] Replace magic links in candidate emails with login link
  • Loading branch information
elceebee authored Jan 17, 2025
2 parents 2deaede + 75dfed1 commit 1b653b7
Show file tree
Hide file tree
Showing 42 changed files with 69 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ class CandidateInterfaceController < ApplicationController
include Authentication

before_action :protect_with_basic_auth
before_action :track_email_click
before_action :authenticate_candidate!, unless: -> { one_login_enabled? }
before_action :set_user_context
before_action :check_cookie_preferences
before_action :check_account_locked
before_action :track_email_click
layout 'application'
alias audit_user current_candidate

Expand Down
22 changes: 12 additions & 10 deletions app/mailers/candidate_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class CandidateMailer < ApplicationMailer

def application_choice_submitted(application_choice)
@application_choice = application_choice
@candidate_magic_link = candidate_magic_link(application_choice.application_form.candidate)

email_for_candidate(
application_choice.application_form,
Expand Down Expand Up @@ -85,7 +84,6 @@ def interview_cancelled(application_choice, interview, reason)
def application_rejected(application_choice)
@course = application_choice.current_course_option.course
@application_choice = RejectedApplicationChoicePresenter.new(application_choice)
@candidate_magic_link = candidate_magic_link(@application_choice.application_form.candidate)

email_for_candidate(application_choice.application_form)
end
Expand All @@ -101,7 +99,6 @@ def application_withdrawn_on_request(application_choice)
def feedback_received_for_application_rejected_by_default(application_choice, show_apply_again_guidance)
@application_choice = RejectedApplicationChoicePresenter.new(application_choice)
@course = @application_choice.current_course_option.course
@candidate_magic_link = candidate_magic_link(@application_choice.application_form.candidate)
@show_apply_again_guidance = show_apply_again_guidance

email_for_candidate(
Expand Down Expand Up @@ -296,7 +293,6 @@ def withdraw_last_application_choice(application_form)
@withdrawn_courses = application_form.application_choices.select(&:withdrawn?)
@withdrawn_course_names = @withdrawn_courses.map { |application_choice| "#{application_choice.current_course_option.course.name_and_code} at #{application_choice.current_course_option.course.provider.name}" }
@rejected_course_choices_count = application_form.application_choices.select(&:rejected?).count
@candidate_magic_link = candidate_magic_link(application_form.candidate)

email_for_candidate(
application_form,
Expand All @@ -308,7 +304,6 @@ def decline_last_application_choice(application_choice)
@declined_course = application_choice
@declined_course_name = "#{application_choice.current_course_option.course.name_and_code} at #{application_choice.current_course_option.course.provider.name}"
@rejected_course_choices_count = application_choice.self_and_siblings.select(&:rejected?).count
@candidate_magic_link = candidate_magic_link(application_choice.application_form.candidate)

email_for_candidate(
application_choice.application_form,
Expand All @@ -320,7 +315,6 @@ def offer_withdrawn(application_choice)
@course_name_and_code = application_choice.current_course_option.course.name_and_code
@provider_name = application_choice.current_course_option.provider.name
@withdrawal_reason = application_choice.offer_withdrawal_reason
@candidate_magic_link = candidate_magic_link(application_choice.application_form.candidate)

email_for_candidate(
application_choice.application_form,
Expand Down Expand Up @@ -453,6 +447,7 @@ def nudge_unsubmitted(application_form)

def nudge_unsubmitted_with_incomplete_references(application_form)
@application_form = application_form
@references_link = candidate_interface_references_review_url(utm_args)
email_for_candidate(
application_form,
subject: I18n.t!('candidate_mailer.nudge_unsubmitted_with_incomplete_references.subject'),
Expand All @@ -470,6 +465,7 @@ def nudge_unsubmitted_with_incomplete_courses(application_form)

def nudge_unsubmitted_with_incomplete_personal_statement(application_form)
@application_form = application_form
@personal_statement_link = candidate_interface_new_becoming_a_teacher_url(utm_args)
email_for_candidate(
application_form,
subject: I18n.t!('candidate_mailer.nudge_unsubmitted_with_incomplete_personal_statement.subject'),
Expand Down Expand Up @@ -533,9 +529,12 @@ def email_for_candidate(application_form, args = {})
notify_email(mailer_options)
end

def candidate_magic_link(candidate)
raw_token = candidate.create_magic_link_token!
candidate_interface_authenticate_url({ token: raw_token }.merge(utm_args))
def sign_in_link
candidate_interface_account_url(utm_args)
end

def application_choices_link
candidate_interface_application_choices_url(utm_args)
end

def candidate_realistic_job_preview_link(candidate)
Expand All @@ -547,7 +546,10 @@ def candidate_unsubscribe_link(candidate)
candidate_interface_unsubscribe_from_emails_url(token:)
end

helper_method :candidate_magic_link, :candidate_realistic_job_preview_link, :candidate_unsubscribe_link
helper_method :sign_in_link,
:application_choices_link,
:candidate_realistic_job_preview_link,
:candidate_unsubscribe_link

def uid
@uid ||= EmailLogInterceptor.generate_reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ All you need to do is:

[Try the realistic job preview tool](<%= candidate_realistic_job_preview_link(@application_form.candidate) %>) to get insights into life in the classroom. Respond to video scenarios and get instant feedback on your suitability for a career in teaching.

[Sign in to apply again](<%= @candidate_magic_link %>).
[Sign in to apply again](<%= application_choices_link %>).
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hello <%= @application_form.first_name %>

You have submitted an application for <%= @application_choice.course_option.course.name_and_code %> at <%= @application_choice.course_option.course.provider.name %>.

[Sign in to your account to check the progress of your application](<%= @candidate_magic_link %>).
[Sign in to your account to check the progress of your application](<%= application_choices_link %>).

Your training provider will contact you if they would like to organise an interview.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The application deadline has passed for teacher training courses starting in the

You can update your details to get ready to apply for courses starting in the <%= @next_academic_year %> academic year. You will be able to apply for these courses from <%= @apply_reopens_date %>.

[Sign into your account to update your details](<%= candidate_magic_link(@application_form.candidate) %>).
[Sign into your account to update your details](<%= sign_in_link %>).

# Get help

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/application_rejected.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ This year, more people than ever are choosing to apply again.

<%= render 'understand_your_professional_strengths' %>

[Sign in to apply again](<%= @candidate_magic_link %>).
[Sign in to apply again](<%= application_choices_link %>).

<%= render 'application_rejected_get_help' %>
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/application_submitted.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Hello <%= @application_form.first_name %>

<% end %>

[Sign in to your account to check the progress of your application](<%= @candidate_magic_link %>).
[Sign in to your account to check the progress of your application](<%= application_choices_link %>).

<% if @application_form.application_choices.count > 1 %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ To give yourself the best chance of success, you can apply to another training p

Candidates who apply for 4 or more courses are more likely to receive an offer.

[Sign into your account](<%= candidate_magic_link(@application_form.candidate) %>) to apply for another course.
[Sign into your account](<%= application_choices_link %>) to apply for another course.

You can also contact <%= @provider_name %> to check on your application.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ While you wait for a response on these applications, you can apply to <%= @choic

Candidates who apply for 4 or more courses are more likely to receive an offer.

[Sign into your account](<%= candidate_magic_link(@application_form.candidate) %>) to apply for another course.
[Sign into your account](<%= application_choices_link %>) to apply for another course.

<%= render 'understand_your_professional_strengths' %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/changed_offer.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The new offer is:
<% end %>


[Sign in to your account to respond to your offer](<%= candidate_magic_link(@application_choice.application_form.candidate) %>).
[Sign in to your account to respond to your offer](<%= application_choices_link %>).

Contact <%= @current_course_option.course.provider.name %> directly if you have any questions about this.

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/chase_reference.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You can sign into your account to:
- ask someone else for a reference


[Sign into your account](<%= candidate_magic_link(@application_form.candidate) %>).
[Sign into your account](<%= sign_in_link %>).

<%= @provider_name %> must check your references before they can confirm your place on the course. Contact them if you need help getting references or choosing who to ask.

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/chase_reference_again.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You can sign into your account to:
- cancel the request for a reference


[Sign into your account](<%= candidate_magic_link(@application_form.candidate) %>).
[Sign into your account](<%= sign_in_link %>).

Contact <%= @provider_name %> if you need help getting references or choosing who to ask.

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/conditions_met.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can sign into your account if you need to check the progress of your referen
Remember to complete your subject knowledge enhancement (SKE) course to meet the conditions of this offer.
<% end %>

[Sign into your account](<%= candidate_magic_link(@application_form.candidate) %>).
[Sign into your account](<%= sign_in_link %>).

#If you are unable to start training in <%= @start_date %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/conditions_not_met.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ All you need to do is:
- make sure you are happy with your personal statement
- find a course and submit another application

[Sign in to apply again](<%= candidate_magic_link(@application_form.candidate) %>).
[Sign in to apply again](<%= application_choices_link %>).

<%= render 'get_help_teacher_training_adviser' %>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ On <%= @application_choice.offer_deferred_at.to_fs(:govuk_date) %>, <%= @course_

You will shortly receive an email to confirm the offer. If you do not receive this, you should contact <%= @course_option.course.provider.name %>.

[Sign in to your account to see your deferred offer](<%= candidate_magic_link(@application_choice.application_form.candidate) %>).
[Sign in to your account to see your deferred offer](<%= sign_in_link %>).

<%= render 'get_help_teacher_training_adviser' %>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Dear <%= @application_form.first_name %>
<% end %>

[Submit your application for teacher training](<%= candidate_magic_link(@application_form.candidate) %>) as soon as you can to get on a course starting in the <%= RecruitmentCycle.current_year %> to <%= RecruitmentCycle.next_year %> academic year.
[Submit your application for teacher training](<%= application_choices_link %>) as soon as you can to get on a course starting in the <%= RecruitmentCycle.current_year %> to <%= RecruitmentCycle.next_year %> academic year.

<%= "The deadline to submit your application is #{CycleTimetable.date(:apply_deadline).to_fs(:govuk_time)} on #{CycleTimetable.apply_deadline.to_fs(:govuk_date)} but courses may fill up before then." %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Dear <%= @application_form.first_name %>

<%= "You must submit your application by #{l(CycleTimetable.apply_deadline.to_date, format: :no_year)} if you want to start teacher training this year." %>

[Sign into your account to submit your application](<%= candidate_magic_link(@application_form.candidate) %>).
[Sign into your account to submit your application](<%= application_choices_link %>).

Need help writing a strong application? You can [get a teacher training adviser](<%= email_link_with_utm_params I18n.t('get_into_teaching.url_get_an_adviser_start'), 'eoc_deadline_reminder', @application_form.phase %>) for free, one-to-one support.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ They’ve now given you the following feedback:
<%= render 'reasons_for_rejection' %>

<% if @show_apply_again_guidance %>
If this was useful, [use your feedback to strengthen your application and apply again](<%= @candidate_magic_link %>).
If this was useful, [use your feedback to strengthen your application and apply again](<%= application_choices_link %>).
<% end %>

<%= render 'get_help_teacher_training_adviser' %>
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/find_has_opened.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can start preparing your applications and submit them from 9am on <%= @apply

Courses can fill up quickly, so apply as soon as you can.

[Start preparing your applications](<%= candidate_magic_link(@application_form.candidate) %>).
[Start preparing your applications](<%= sign_in_link %>).

Training providers offer places on courses as people apply throughout the year. Courses stay open until they are full.

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/new_cycle_has_started.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You can now apply for teacher training courses that start in the <%= @academic_y

Courses can fill up quickly, so apply as soon as you are ready.

[Sign into your account to apply for courses](<%= candidate_magic_link(@application_form.candidate) %>).
[Sign into your account to apply for courses](<%= sign_in_link %>).

# Get a teacher training adviser

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/new_offer_made.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ The training provider will usually pay for the criminal records checks.

Contact <%= @provider_name %> if you have any questions about this.

[Sign into your account to respond to your offer](<%= candidate_magic_link(@application_form.candidate) %>).
[Sign into your account to respond to your offer](<%= application_choices_link %>).

<%= render 'get_help_teacher_training_adviser' %>
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/new_referee_request.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You can sign into your account to:


<% end %>
[Sign into your account](<%= candidate_magic_link(@candidate) %>).
[Sign into your account](<%= sign_in_link %>).

<%= @provider_name %> must check your references before they can confirm your place on the course. Contact them if you need help getting references or choosing who to ask.

Expand Down
4 changes: 2 additions & 2 deletions app/views/candidate_mailer/nudge_unsubmitted.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ Dear <%= @application_form.first_name %>

It looks like your teacher training application is ready to submit.

If you are ready, [sign in to your account to submit your application now](<%= candidate_magic_link(@application_form.candidate) %>).
If you are ready, [sign in to your account to submit your application now](<%= application_choices_link %>).

Popular courses fill up quickly and places are allocated as soon as people apply. Submit your application as soon as you are ready to avoid missing out on a limited number of course places.

You may need to complete a [subject knowledge enhancement](<%= email_link_with_utm_params(t('get_into_teaching.url_subject_knowledge_enhancement'), 'nudge_unsubmitted', @application_form.phase) %>) (SKE) course and other conditions before starting your training.

[Apply now to make sure you have enough time](<%= candidate_magic_link(@application_form.candidate) %>)
[Apply now to make sure you have enough time](<%= application_choices_link %>)

Some subjects and courses have bursaries of up to £29,000 and scholarships of up to £31,000. These courses fill up more quickly than other courses.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ Hello <%= @application_form.first_name %>

You have not applied to any teacher training courses yet.

[Sign into your account to apply for up to 4 courses](<%= candidate_magic_link(@application_form.candidate) %>).
[Sign into your account to apply for up to 4 courses](<%= application_choices_link %>).

Popular courses fill up quickly and places are allocated as soon as people apply. Submit your application as soon as you are ready to avoid missing out on a limited number of course places.

You may need to complete a [subject knowledge enhancement](<%= email_link_with_utm_params(t('get_into_teaching.url_subject_knowledge_enhancement'), 'nudge_unsubmitted_with_incomplete_courses', @application_form.phase) %>) (SKE) course and other conditions before starting your training.

[Apply now to make sure you have enough time](<%= candidate_magic_link(@application_form.candidate) %>)
[Apply now to make sure you have enough time](<%= application_choices_link %>)

Some subjects and courses have bursaries of up to £29,000 and scholarships of up to £31,000. These courses fill up more quickly than other courses.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hello <%= @application_form.first_name %>

You have not marked your personal statement as complete.

[Sign in to your account to complete your teacher training application](<%= candidate_magic_link(@application_form.candidate) %>)
[Sign in to your account to complete your teacher training application](<%= @personal_statement_link %>)

# Get help with your personal statement

Expand All @@ -22,7 +22,7 @@ Popular courses fill up quickly and places are allocated as soon as people apply

You may need to complete a [subject knowledge enhancement](<%= email_link_with_utm_params(t('get_into_teaching.url_subject_knowledge_enhancement'), 'nudge_unsubmitted_with_incomplete_personal_statement', @application_form.phase) %>) (SKE) course and other conditions before starting your training.

[Apply now to make sure you have enough time](<%= candidate_magic_link(@application_form.candidate) %>)
[Apply now to make sure you have enough time](<%= sign_in_link %>)

<%= render 'understand_your_professional_strengths' %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You have not completed the references section of your teacher training applicati

You need to give details of 2 people who can give you a reference. They’ll only be contacted if you accept an offer on a course.

[Sign into your account to complete the references section](<%= candidate_magic_link(@application_form.candidate) %>).
[Sign into your account to complete the references section](<%= @references_link %>).

# Who to choose to give you a reference

Expand Down Expand Up @@ -37,7 +37,7 @@ Popular courses fill up quickly and places are allocated as soon as people apply

You may need to complete a [subject knowledge enhancement](<%= email_link_with_utm_params(t('get_into_teaching.url_subject_knowledge_enhancement'), 'nudge_unsubmitted_no_references', @application_form.phase) %>) (SKE) course and other conditions before starting your training.

[Apply now to make sure you have enough time](<%= candidate_magic_link(@application_form.candidate) %>)
[Apply now to make sure you have enough time](<%= sign_in_link %>)

<%= render 'understand_your_professional_strengths' %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/offer_10_day.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Congratulations! 10 days ago, you received an offer for a place on the course, <

You should respond to your offer as soon as you can. Most candidates respond to their offer in 15 working days.

[Sign in to your account to respond to your offer](<%= candidate_magic_link(@candidate) %>).
[Sign in to your account to respond to your offer](<%= application_choices_link %>).

Accepting your offer is your first step to becoming an amazing teacher and making a positive difference.

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/offer_20_day.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Hello <%= @first_name %>

You must respond to your offer as soon as you can. Most candidates respond to their offer in 15 working days.

[Sign in to your account to respond to your offer](<%= candidate_magic_link(@candidate) %>).
[Sign in to your account to respond to your offer](<%= application_choices_link %>).

If you have any questions about your training, you can contact the training provider.

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/offer_30_day.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Hello <%= @first_name %>

You must respond to your offer as soon as you can. This will allow other candidates the chance to apply for a place on the course.

[Sign in to your account to respond to your offer now](<%= candidate_magic_link(@candidate) %>).
[Sign in to your account to respond to your offer now](<%= application_choices_link %>).

If you are waiting on other offers or are unsure about accepting this offer, contact the training provider.

Expand Down
2 changes: 1 addition & 1 deletion app/views/candidate_mailer/offer_40_day.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Hello <%= @first_name %>

You must respond to your offer, even if you decline it. This will allow other candidates the chance to apply for a place on the course.

[Sign in to your account to respond to your offer now](<%= candidate_magic_link(@candidate) %>).
[Sign in to your account to respond to your offer now](<%= application_choices_link %>).

If you are waiting on other offers or are unsure about accepting this offer, contact the training provider.

Expand Down
Loading

0 comments on commit 1b653b7

Please sign in to comment.