Files
sure/app/views/oidc_accounts/link.html.erb
Copilot 1ee20ab3a6 Eliminate code duplication in OIDC identity creation (#230)
* Eliminate duplication by using create_from_omniauth method

- Updated OidcIdentity.create_from_omniauth to set last_authenticated_at
- Refactored OidcAccountsController to use create_from_omniauth instead of direct create! calls
- Updated test to verify last_authenticated_at is set by create_from_omniauth

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Extract auth hash building into private helper method

- Added build_auth_hash helper method to eliminate OpenStruct creation duplication
- Both create_link and create_user actions now use the same helper

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>

* Linter fix

* Fix button style on OIDC link step

* Fix dark mode styles

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2025-10-25 22:23:28 +02:00

75 lines
2.4 KiB
Plaintext

<%
header_title @user_exists ? "Link OIDC Account" : "Create Account"
%>
<% if @user_exists %>
<div class="mb-6 p-4 bg-yellow-50 border border-yellow-200 rounded-md">
<h3 class="text-sm font-medium text-yellow-800 mb-2">Verify Your Identity</h3>
<p class="text-sm text-yellow-700">
To link your <%= @pending_auth["provider"] %> account<% if @pending_auth["email"].present? %> (<%= @pending_auth["email"] %>)<% end %>,
please verify your identity by entering your password.
</p>
</div>
<%= styled_form_with url: create_link_oidc_account_path, class: "space-y-4", data: { turbo: false } do |form| %>
<%= form.email_field :email,
label: "Email",
autofocus: false,
autocomplete: "email",
required: "required",
placeholder: "Enter your email",
value: @email %>
<%= form.password_field :password,
label: "Password",
required: "required",
placeholder: "Enter your password",
autocomplete: "current-password" %>
<div class="text-sm text-gray-600 mt-2">
<p>This helps ensure that only you can link external accounts to your profile.</p>
</div>
<%= form.submit "Link Account" %>
<% end %>
<% else %>
<div class="mb-6 p-4 bg-blue-50 border border-blue-200 rounded-md">
<h3 class="text-sm font-medium text-blue-800 mb-2">Create New Account</h3>
<p class="text-sm text-blue-700">
No account found with the email <strong><%= @pending_auth["email"] %></strong>.
Click below to create a new account using your <%= @pending_auth["provider"] %> identity.
</p>
</div>
<div class="space-y-4">
<div class="p-4 bg-container border border-secondary rounded-md">
<p class="text-sm text-primary">
<strong>Email:</strong> <%= @pending_auth["email"] %>
</p>
<% if @pending_auth["name"].present? %>
<p class="text-sm text-primary mt-2">
<strong>Name:</strong> <%= @pending_auth["name"] %>
</p>
<% end %>
</div>
<%= render DS::Button.new(
text: "Create Account",
href: create_user_oidc_account_path,
full_width: true,
variant: :primary,
method: :post,
data: { turbo: false }
) %>
</div>
<% end %>
<div class="mt-6 text-center">
<%= render DS::Link.new(
text: "Cancel",
href: new_session_path,
variant: :default,
class: "font-medium text-sm text-primary hover:underline transition"
) %>
</div>