diff --git a/app/components/auth_welcome.rb b/app/components/auth_welcome.rb index 8063c8da..1c58204a 100644 --- a/app/components/auth_welcome.rb +++ b/app/components/auth_welcome.rb @@ -1,10 +1,11 @@ class Components::AuthWelcome < Components::Base include Phlex::Rails::Helpers::DistanceOfTimeInWordsToNow - def initialize(headline:, subtitle:, return_to: nil) + def initialize(headline:, subtitle:, return_to: nil, login_hint: nil) @headline = headline @subtitle = subtitle @return_to = return_to + @login_hint = login_hint end def view_template @@ -43,7 +44,8 @@ def render_actions placeholder: t("identities.email_placeholder"), required: true, autocomplete: "email", - style: "width: 100%;" + style: "width: 100%;", + value: @login_hint ) small(style: "color: var(--muted-color); display: block; margin-top: 0.5rem;") do diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 8a7cdb1d..b01c2e0e 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -11,13 +11,14 @@ def welcome end def oauth_welcome - # Extract client_id from the return_to URL + # Extract client_id and login_hint from the return_to URL @return_to = params[:return_to] if @return_to.present? uri = URI.parse(@return_to) params_hash = URI.decode_www_form(uri.query || "").to_h client_id = params_hash["client_id"] @program = Program.find_by(uid: client_id) if client_id + @login_hint = params_hash["login_hint"] end @program ||= nil diff --git a/app/views/static_pages/oauth_welcome.html.erb b/app/views/static_pages/oauth_welcome.html.erb index d9315e89..1bcd72b4 100644 --- a/app/views/static_pages/oauth_welcome.html.erb +++ b/app/views/static_pages/oauth_welcome.html.erb @@ -2,5 +2,6 @@ <%= render Components::AuthWelcome.new( headline: "Continue to #{service_name}", subtitle: "Sign in or create an account to continue", - return_to: @return_to + return_to: @return_to, + login_hint: @login_hint ) %>