Class: MetadataPresenter::SaveAndReturnController
Instance Method Summary
collapse
#label_text, #page_slug
#allow_analytics?, #analytics_cookie_name, #analytics_tags_present?, #answered?, #authorised_session!, #back_link, #external_or_relative_link, #get_saved_progress, #increment_record_counter, #invalidate_record, #load_autocomplete_items, #load_page_content, #maintenance_mode?, #reload_user_data, #require_basic_auth, #save_form_progress, #session_authorised?, #show_cookie_confirmation?, #show_cookie_request?
Instance Method Details
#confirm_email ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/controllers/metadata_presenter/save_and_return_controller.rb', line 47
def confirm_email
@email_confirmation = EmailConfirmation.new(confirmation_params[:email_confirmation])
if @email_confirmation.valid?
session['saved_form']['email'] = @email_confirmation.email_confirmation
response = save_form_progress
if response.status == 500
internal_server_error and return
end
payload = response.body.merge(email: @email_confirmation.email_confirmation).deep_symbolize_keys
create_save_and_return_submission(payload)
redirect_to '/save/progress_saved'
else
render :email_confirmation, status: :unprocessable_entity
end
end
|
#confirmed_email ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/controllers/metadata_presenter/save_and_return_controller.rb', line 11
def confirmed_email
email = session['saved_form']['email']
session['saved_form']['email'] = nil
session['saved_form']['user_id'] = nil
session['saved_form']['user_token'] = nil
session['saved_form']['secret_answer'] = nil
session['saved_form']['secret_question'] = nil
session['saved_form']['secret_question_text'] = nil
session['saved_form']['service_slug'] = nil
session['saved_form']['service_version'] = nil
email
end
|
#create ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/metadata_presenter/save_and_return_controller.rb', line 24
def create
@saved_form = SavedForm.new
@saved_form.populate_param_values(saved_form_params)
@saved_form.secret_question_text = text_for(params['saved_form']['secret_question'])
@saved_form.secret_question = params['saved_form']['secret_question']
@saved_form.populate_service_values(service)
@saved_form.populate_session_values(session)
@saved_form.service_slug = service_slug
if @saved_form.valid?
@saved_form.secret_question = @saved_form.secret_question_text
session[:saved_form] = @saved_form
redirect_to '/save/email_confirmation'
else
render :show, params: { page_slug: params[:page_slug], status: :unprocessable_entity }
end
end
|
#email_confirmation ⇒ Object
42
43
44
45
|
# File 'app/controllers/metadata_presenter/save_and_return_controller.rb', line 42
def email_confirmation
@saved_form = session[:saved_form]
@email_confirmation = EmailConfirmation.new(@saved_form['email'])
end
|
#save_progress ⇒ Object
66
67
68
69
70
71
|
# File 'app/controllers/metadata_presenter/save_and_return_controller.rb', line 66
def save_progress
session['saved_form']['user_id'] = nil
session['saved_form']['user_token'] = nil
session['user_id'] = nil
session['user_token'] = nil
end
|
#secret_questions ⇒ Object
73
74
75
76
77
78
79
|
# File 'app/controllers/metadata_presenter/save_and_return_controller.rb', line 73
def secret_questions
[
OpenStruct.new(id: 1, name: I18n.t('presenter.save_and_return.secret_questions.one')),
OpenStruct.new(id: 2, name: I18n.t('presenter.save_and_return.secret_questions.two')),
OpenStruct.new(id: 3, name: I18n.t('presenter.save_and_return.secret_questions.three'))
]
end
|
#show ⇒ Object
7
8
9
|
# File 'app/controllers/metadata_presenter/save_and_return_controller.rb', line 7
def show
@saved_form = SavedForm.new
end
|
#text_for(question) ⇒ Object
81
82
83
84
85
|
# File 'app/controllers/metadata_presenter/save_and_return_controller.rb', line 81
def text_for(question)
return nil if question.blank?
secret_questions.select { |s| s.id.to_s == question.to_s }.first.name
end
|