smbCloud Auth confirmation

Seto Elkahfi committed Jun 17, 2026 at 15:25 UTC 91b0d1e003b7709feb01a2183880e5d001e14966
3 files changed +80
app/controllers/confirmations_controller.rb
+16
index 821dd99..9ec3c04 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -7,6 +7,22 @@ class ConfirmationsController < ApplicationController def new end + # GET /auth/confirmed + # Landing page for the link in the confirmation email. smbCloud verifies the + # token on its side, then redirects here with ?status=success or + # ?status=failed&message=... (see redirect_or_render_confirmation in the + # smbCloud client auth_users controller). + def confirmed + @succeeded = params[:status].to_s == "success" + @message = params[:message].to_s.strip.presence + + # "Already confirmed" is a benign state, not a real failure: the account is + # fine and the user just needs to sign in. smbCloud reports it as + # status=failed with this message, so detect it and treat it gently rather + # than showing the scary failure UI with a pointless "resend" button. + @already_confirmed = !@succeeded && @message.to_s.match?(/already confirmed/i) + end + # POST /auth/confirmation/resend def create email = params[:email].to_s.strip.downcase
app/views/confirmations/confirmed.html.erb
+60
new file mode 100644 index 0000000..5f17849 --- /dev/null +++ b/app/views/confirmations/confirmed.html.erb @@ -0,0 +1,60 @@ +<% content_for :title, @succeeded ? "Email confirmed" : (@already_confirmed ? "Already confirmed" : "Confirmation failed") %> + +<div class="min-h-screen bg-surface-900 flex flex-col items-center justify-center px-4 py-16"> + + <div class="mb-10 flex flex-col items-center gap-3"> + <%= link_to root_path, class: "flex items-center gap-3 text-gray-100 hover:text-brand-500 transition-colors" do %> + <img src="/icon.png" alt="siGit" class="h-9 w-auto"> + <span class="text-xl font-semibold tracking-tight">Code &amp; Deploy</span> + <% end %> + </div> + + <div class="w-full max-w-sm"> + <div class="border border-surface-500 rounded bg-surface-700 px-8 py-8 text-center"> + + <% if @succeeded %> + <div class="mx-auto mb-5 flex h-12 w-12 items-center justify-center rounded-full bg-green-900/30 text-green-400"> + <svg class="w-6 h-6" viewBox="0 0 16 16" fill="currentColor"> + <path d="M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm3.78 5.28-4.5 4.5a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 1 1 1.06-1.06l1.47 1.47 3.97-3.97a.75.75 0 1 1 1.06 1.06z"/> + </svg> + </div> + <h1 class="text-lg font-semibold text-gray-100">Email confirmed</h1> + <p class="mt-2 text-sm text-gray-400 leading-relaxed"> + Your account is ready. Sign in to start hosting code and models. + </p> + <%= link_to "Sign in", signin_path, class: "btn-primary w-full justify-center py-2.5 mt-6" %> + + <% elsif @already_confirmed %> + <div class="mx-auto mb-5 flex h-12 w-12 items-center justify-center rounded-full bg-brand-500/15 text-brand-400"> + <svg class="w-6 h-6" viewBox="0 0 16 16" fill="currentColor"> + <path d="M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm3.78 5.28-4.5 4.5a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 1 1 1.06-1.06l1.47 1.47 3.97-3.97a.75.75 0 1 1 1.06 1.06z"/> + </svg> + </div> + <h1 class="text-lg font-semibold text-gray-100">You're all set</h1> + <p class="mt-2 text-sm text-gray-400 leading-relaxed"> + This email is already confirmed. Just sign in to continue. + </p> + <%= link_to "Sign in", signin_path, class: "btn-primary w-full justify-center py-2.5 mt-6" %> + + <% else %> + <div class="mx-auto mb-5 flex h-12 w-12 items-center justify-center rounded-full bg-red-900/30 text-red-400"> + <svg class="w-6 h-6" viewBox="0 0 16 16" fill="currentColor"> + <path d="M8 1a7 7 0 1 1 0 14A7 7 0 0 1 8 1zm0 3.75a.75.75 0 0 0-.75.75v3.5a.75.75 0 0 0 1.5 0v-3.5A.75.75 0 0 0 8 4.75zm0 7.5a.875.875 0 1 0 0-1.75.875.875 0 0 0 0 1.75z"/> + </svg> + </div> + <h1 class="text-lg font-semibold text-gray-100">Confirmation failed</h1> + <p class="mt-2 text-sm text-gray-400 leading-relaxed"> + <%= @message || "This confirmation link is invalid or has expired. You can request a new one." %> + </p> + <%= link_to "Resend confirmation email", resend_confirmation_path, class: "btn-primary w-full justify-center py-2.5 mt-6" %> + <% end %> + + </div> + + <p class="mt-6 text-center text-xs text-gray-500"> + Back to + <%= link_to "Sign in", signin_path, class: "text-gray-400 hover:text-gray-200 underline underline-offset-2" %> + </p> + </div> + +</div>
config/routes.rb
+4
index 41f130c..6367a16 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -25,6 +25,10 @@ Rails.application.routes.draw do get "/auth/signup", to: "registrations#new", as: :signup post "/auth/signup", to: "registrations#create", as: :signup_create + # Email confirmation landing — smbCloud confirms the token server-side, then + # redirects here with ?status=success or ?status=failed&message=... + get "/auth/confirmed", to: "confirmations#confirmed", as: :auth_confirmed + # Resend confirmation email get "/auth/confirmation/resend", to: "confirmations#new", as: :resend_confirmation post "/auth/confirmation/resend", to: "confirmations#create"