diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index a117aecff..270b89b2e 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -17,4 +17,10 @@ class Auth::SessionsController < Devise::SessionsController super end end + +private + + def after_sign_in_path_for(resource) + params.dig("user", "start").present? ? case_logs_path : super + end end diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 70a4bfc0e..edfe427a0 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -19,6 +19,7 @@ autocomplete: "current-password" %> + <%= f.hidden_field :start, value: request["start"] %> <%= f.govuk_submit "Sign in" %> diff --git a/app/views/start/index.html.erb b/app/views/start/index.html.erb index d3de2d344..7ba5625fa 100644 --- a/app/views/start/index.html.erb +++ b/app/views/start/index.html.erb @@ -16,9 +16,10 @@
The data will be used to update the national record for social housing. It will also help to inform policy about the cost of social housing and what type of housing needs to be built.
This service is only for social housing in England.
+ <% start_path = current_user ? case_logs_path : (user_session_path + "?start=true") %> <%= govuk_start_button( text: 'Start now', - href: user_session_path + href: start_path ) %>