Skip to content

Commit 172d63f

Browse files
kcdragonclaude
andauthored
Add dev-only /auto_sign_in path to sign in the first user (#37)
Signs in User.first without a password to speed up local development. The route is only mounted in development and the controller also 404s outside development, so it can never be a backdoor in production. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5475cf6 commit 172d63f

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class AutoSignInController < ApplicationController
2+
allow_unauthenticated_access
3+
allow_without_organization
4+
5+
before_action :ensure_development
6+
7+
def create
8+
if (user = User.first)
9+
start_new_session_for user
10+
redirect_to root_path
11+
else
12+
redirect_to new_registration_path, alert: "No users exist yet."
13+
end
14+
end
15+
16+
private
17+
18+
def ensure_development
19+
raise ActionController::RoutingError, "Not Found" unless Rails.env.development?
20+
end
21+
end

config/routes.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
resource :email_confirmation, only: %i[ new create show ]
77
resource :session
88

9+
# Dev-only convenience: sign in as the first user without a password
10+
get "auto_sign_in", to: "auto_sign_in#create" if Rails.env.development?
11+
912
resources :scenarios do
1013
resource :name, only: %i[ show edit update ], module: :scenarios
1114
resources :allocations, only: %i[ create update destroy ]

0 commit comments

Comments
 (0)