add program return button (#314)

This commit is contained in:
nora
2025-06-13 13:48:21 -04:00
committed by GitHub
parent fe2caf3dc9
commit 8da145d623
5 changed files with 17 additions and 4 deletions

View File

@@ -38,7 +38,7 @@ module Api
end
def magic_link_params
params.permit(:continue_param)
params.permit(:continue_param, return_data: {})
end
end
end

View File

@@ -156,6 +156,7 @@ class SessionsController < ApplicationController
if valid_token
valid_token.mark_used!
session[:user_id] = valid_token.user_id
session[:return_data] = valid_token.return_data || {}
if valid_token.continue_param.present?
redirect_to valid_token.continue_param, notice: "Successfully signed in!"

View File

@@ -14,6 +14,12 @@
<button>Set up another editor</button>
<% end %>
<%= link_to root_path do %>
<button>Done</button>
<% if (url = session.dig(:return_data, "url")) %>
<%= link_to url do %>
<button><%= session.dig(:return_data, "button_text") || "Done" %></button>
<% end %>
<% else %>
<%= link_to root_path do %>
<button>Done</button>
<% end %>
<% end %>

View File

@@ -0,0 +1,5 @@
class AddReturnDataToSignInTokens < ActiveRecord::Migration[8.0]
def change
add_column :sign_in_tokens, :return_data, :jsonb
end
end

3
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_06_11_071124) do
ActiveRecord::Schema[8.0].define(version: 2025_06_13_163710) do
create_schema "pganalyze"
# These are extensions that must be enabled in order to support this database
@@ -464,6 +464,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_071124) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "continue_param"
t.jsonb "return_data"
t.index ["token"], name: "index_sign_in_tokens_on_token"
t.index ["user_id"], name: "index_sign_in_tokens_on_user_id"
end