Skip to content

Commit e204989

Browse files
autologin after omniauth
1 parent cd99575 commit e204989

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

app/rodauth/hacker_rodauth_plugin.rb

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class HackerRodauthPlugin < RodauthPlugin
7979
# Requires the JSON feature
8080
# only_json? false
8181

82-
8382
send_email do |email|
8483
# queue email delivery on the mailer after the transaction commits
8584
db.after_commit { email.deliver_later }
@@ -106,6 +105,25 @@ class HackerRodauthPlugin < RodauthPlugin
106105

107106
# ==> Passwords
108107

108+
# Passwords shorter than 8 characters are considered weak according to OWASP.
109+
# password_minimum_length 8
110+
111+
# Custom password complexity requirements (alternative to password_complexity feature).
112+
# password_meets_requirements? do |password|
113+
# super(password) && password_complex_enough?(password)
114+
# end
115+
# auth_class_eval do
116+
# def password_complex_enough?(password)
117+
# return true if password.match?(/\d/) && password.match?(/[^a-zA-Z\d]/)
118+
# set_password_requirement_error_message(:password_simple, "requires one number and one special character")
119+
# false
120+
# end
121+
# end
122+
123+
# = bcrypt
124+
125+
# bcrypt has a maximum input length of 72 bytes, truncating any extra bytes.
126+
password_maximum_bytes 72 if respond_to?(:password_maximum_bytes)
109127

110128
# ==> Remember Feature
111129

@@ -147,11 +165,17 @@ class HackerRodauthPlugin < RodauthPlugin
147165
# Profile.find_by!(account_id: account_id).destroy
148166
# end
149167

150-
151168
# ==> Redirects
152169

153-
# Redirect to dashboard after omniauth login/create
154-
after_omniauth_create_account { redirect "/hacker_dashboard" }
170+
# Ensure auto-login after omniauth account creation
171+
omniauth_create_account? true
172+
173+
# Redirect to dashboard after omniauth login/create (user is auto-logged in)
174+
after_omniauth_create_account do
175+
# Explicitly login if not already logged in
176+
login_session(account_id) unless logged_in?
177+
redirect "/hacker_dashboard"
178+
end
155179

156180
# Redirect to home after login.
157181
login_redirect "/hacker_dashboard"

0 commit comments

Comments
 (0)