Skip to content

Commit 45693e9

Browse files
authored
Fix: Better redirect handling (#3104)
* Fix: better redirect rendering * Switch to overmind
1 parent 0bc9adf commit 45693e9

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,5 @@ gem "turnout2024", require: "turnout"
131131
gem "solid_queue", "~> 1.1"
132132

133133
gem "mission_control-jobs", "~> 0.5.0"
134+
135+
gem "overmind", "~> 2.5", group: :development

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ GEM
399399
childprocess (>= 0.6.3, < 6)
400400
iniparse (~> 1.4)
401401
rexml (>= 3.3.9)
402+
overmind (2.5.1)
402403
parallel (1.26.3)
403404
parser (3.3.7.1)
404405
ast (~> 2.4.1)
@@ -671,6 +672,7 @@ DEPENDENCIES
671672
mysql2
672673
oj
673674
overcommit
675+
overmind (~> 2.5)
674676
pg
675677
pry-rails
676678
puma

app/controllers/users/registrations_controller.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,21 @@ class Users::RegistrationsController < Devise::RegistrationsController
4545

4646
# GET /resource/token
4747
def token
48-
redirect_to user_session_path if current_user.nil?
49-
current_user.regenerate_authentication_token! if current_user.authentication_token.blank?
48+
if current_user.nil?
49+
redirect_to user_session_path
50+
elsif current_user&.authentication_token.blank?
51+
current_user.regenerate_authentication_token!
52+
end
5053
end
5154

5255
# DELETE /resource/token
5356
def regen_token
54-
redirect_to user_session_path if current_user.nil?
55-
current_user.regenerate_authentication_token!
56-
redirect_to token_user_registration_path
57+
if current_user.nil?
58+
redirect_to user_session_path
59+
else
60+
current_user.regenerate_authentication_token!
61+
redirect_to token_user_registration_path
62+
end
5763
end
5864

5965
# protected

bin/dev

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env sh
22

3-
if gem list --no-installed --exact --silent foreman; then
4-
echo "Installing foreman..."
5-
gem install foreman
6-
fi
7-
83
# Default to port 3000 if not specified
9-
export PORT="${PORT:-3000}"
4+
export PORT="${PORT:-5100}"
5+
6+
if ! command -v overmind 2>&1 >/dev/null; then
7+
gem install overmind
8+
fi
109

11-
exec foreman start -f Procfile.dev --env /dev/null "$@"
10+
exec overmind start -T -f Procfile.dev "$@"

0 commit comments

Comments
 (0)