@@ -12,34 +12,26 @@ class AdminRodauthPlugin < RodauthPlugin
1212 # http://rodauth.jeremyevans.net/documentation.html
1313
1414 # List of authentication features that are loaded.
15- enable (
16- :login ,
17- :remember ,
18- :logout ,
19- # :create_account,
20- # :verify_account,
21- # :verify_account_grace_period,
22- :reset_password ,
23- :reset_password_notify ,
24- # :change_login,
25- # :verify_login_change,
26- :change_password ,
27- :change_password_notify ,
28- :case_insensitive_login ,
29- :internal_request
30- )
15+ enable :login , :remember , :logout , :create_account , :verify_account , :close_account , :reset_password , :reset_password_notify , :password_grace_period , :change_password , :otp , :recovery_codes , :lockout , :active_sessions , :audit_logging , :internal_request
3116
3217 # ==> General
3318
3419 # Prevent rodauth from introspecting the database if we are not using UUIDs
3520 convert_token_id_to_integer? { Admin . columns_hash [ "id" ] . type == :integer }
3621
3722 # Change prefix of table and foreign key column names from default "account"
23+ account_lockouts_table :admin_lockouts
24+ account_login_failures_table :admin_login_failures
3825 accounts_table :admins
26+ active_sessions_account_id_column :admin_id
27+ active_sessions_table :admin_active_session_keys
28+ audit_logging_account_id_column :admin_id
29+ audit_logging_table :admin_authentication_audit_logs
30+ otp_keys_table :admin_otp_keys
31+ recovery_codes_table :admin_recovery_codes
3932 remember_table :admin_remember_keys
4033 reset_password_table :admin_password_reset_keys
41- # verify_account_table :admin_verification_keys
42- # verify_login_change_table :admin_login_change_keys
34+ verify_account_table :admin_verification_keys
4335
4436 # The secret key used for hashing public-facing tokens for various features.
4537 # Defaults to Rails `secret_key_base`, but you can use your own secret key.
@@ -66,7 +58,7 @@ class AdminRodauthPlugin < RodauthPlugin
6658
6759 # Redirect back to originally requested location after authentication.
6860 login_return_to_requested_location? true
69- # two_factor_auth_return_to_requested_location? true # if using MFA
61+ two_factor_auth_return_to_requested_location? true
7062
7163 # Autologin the user after they have reset their password.
7264 # reset_password_autologin? true
@@ -81,41 +73,26 @@ class AdminRodauthPlugin < RodauthPlugin
8173 # Requires the JSON feature
8274 # only_json? false
8375
76+ # Only ask for password after asking for the login
77+ use_multi_phase_login? true
78+
8479 # ==> Emails
8580 # Use a custom mailer for delivering authentication emails.
8681
87- # create_reset_password_email do
88- # Rodauth::AdminMailer.reset_password(
89- # self.class.configuration_name,
90- # account_id, reset_password_key_value
91- # )
92- # end
93-
94- # create_verify_account_email do
95- # Rodauth::AdminMailer.verify_account(
96- # self.class.configuration_name,
97- # account_id, verify_account_key_value
98- # )
99- # end
100-
101- # create_verify_login_change_email do |_login|
102- # Rodauth::AdminMailer.verify_login_change(
103- # self.class.configuration_name,
104- # account_id, verify_login_change_key_value
105- # )
106- # end
82+ create_reset_password_email do
83+ Rodauth ::AdminMailer . reset_password ( self . class . configuration_name , account_id , reset_password_key_value )
84+ end
10785
108- create_password_changed_email do
109- Rodauth ::AdminMailer . change_password_notify (
110- self . class . configuration_name , account_id
111- )
86+ create_verify_account_email do
87+ Rodauth ::AdminMailer . verify_account ( self . class . configuration_name , account_id , verify_account_key_value )
11288 end
11389
11490 create_reset_password_notify_email do
115- Rodauth ::AdminMailer . reset_password_notify (
116- self . class . configuration_name ,
117- account_id
118- )
91+ Rodauth ::AdminMailer . reset_password_notify ( self . class . configuration_name , account_id )
92+ end
93+
94+ create_unlock_account_email do
95+ Rodauth ::AdminMailer . unlock_account ( self . class . configuration_name , account_id , unlock_account_key_value )
11996 end
12097
12198 send_email do |email |
@@ -131,6 +108,7 @@ class AdminRodauthPlugin < RodauthPlugin
131108 # flash_error_key :error # default is :alert
132109
133110 # Override default flash messages.
111+ two_factor_not_setup_error_flash "You need to setup two factor authentication"
134112 # create_account_notice_flash "Your account has been created. Please verify your account by visiting the confirmation link sent to your email address."
135113 # require_login_error_flash "Login is required for accessing this page"
136114 # login_notice_flash nil
@@ -180,6 +158,11 @@ class AdminRodauthPlugin < RodauthPlugin
180158
181159 # ==> Hooks
182160
161+ # Prevent using the web to sign up.
162+ before_create_account_route do
163+ request . halt unless internal_request?
164+ end
165+
183166 # Validate custom fields in the create account form.
184167 # before_create_account do
185168 # throw_error_status(422, "name", "must be present") if param("name").empty?
@@ -190,28 +173,28 @@ class AdminRodauthPlugin < RodauthPlugin
190173 # Profile.create!(account_id: account_id, name: param("name"))
191174 # end
192175
193- # # Do additional cleanup after the account is closed.
194- # # after_close_account do
195- # # Profile.find_by!(account_id: account_id).destroy
196- # # end
197- # create_account_route "register"
176+ # Do additional cleanup after the account is closed.
177+ # after_close_account do
178+ # Profile.find_by!(account_id: account_id).destroy
179+ # end
198180
199181 # ==> Redirects
200182
201- # # Redirect to home after login.
202- # create_account_redirect "/admin_dashboard"
183+ # Redirect to home after login.
184+ create_account_redirect "/admin_dashboard"
203185
204186 # Redirect to home after login.
205187 login_redirect "/admin_dashboard"
206188
207189 # Redirect to home page after logout.
208- logout_redirect "/"
190+ logout_redirect "/admin_dashboard "
209191
210- # # Redirect to wherever login redirects to after account verification.
211- # verify_account_redirect { login_redirect }
192+ # Redirect to wherever login redirects to after account verification.
193+ verify_account_redirect { login_redirect }
212194
213195 # Redirect to login page after password reset.
214196 reset_password_redirect { login_path }
197+
215198 # ==> Deadlines
216199 # Change default deadlines for some actions.
217200 # verify_account_grace_period 3.days.to_i
0 commit comments