66use CodeIgniter \Config \Factories ;
77use CodeIgniter \Events \Events ;
88use CodeIgniter \HTTP \RedirectResponse ;
9+ use CodeIgniter \Shield \Authentication \Actions \ActionInterface ;
910use CodeIgniter \Shield \Authentication \Authenticators \Session ;
1011use CodeIgniter \Shield \Entities \User ;
1112use CodeIgniter \Shield \Models \UserModel ;
@@ -89,15 +90,8 @@ public function registerAction(): RedirectResponse
8990
9091 // If an action has been defined for login, start it up.
9192 $ actionClass = setting ('Auth.actions ' )['register ' ] ?? null ;
92-
9393 if (! empty ($ actionClass )) {
94- $ action = Factories::actions ($ actionClass ); // @phpstan-ignore-line
95-
96- if (method_exists ($ action , 'afterRegister ' )) {
97- $ action ->afterRegister ($ user );
98- }
99-
100- session ()->set ('auth_action ' , $ actionClass );
94+ $ this ->startUpAction ($ actionClass , $ user );
10195
10296 return redirect ()->to ('auth/a/show ' );
10397 }
@@ -113,6 +107,23 @@ public function registerAction(): RedirectResponse
113107 ->with ('message ' , lang ('Auth.registerSuccess ' ));
114108 }
115109
110+ /**
111+ * @param class-string<ActionInterface> $actionClass
112+ */
113+ private function startUpAction (string $ actionClass , User $ user )
114+ {
115+ // @TODO I want to move this logic to Authenticators\Session,
116+ // and create register() method in Authenticators\Session.
117+
118+ $ action = Factories::actions ($ actionClass ); // @phpstan-ignore-line
119+
120+ if (method_exists ($ action , 'afterRegister ' )) {
121+ $ action ->afterRegister ($ user );
122+ }
123+
124+ session ()->set ('auth_action ' , $ actionClass );
125+ }
126+
116127 /**
117128 * Returns the User provider
118129 */
0 commit comments