File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ class RegisterController extends BaseController
2727 */
2828 public function registerView ()
2929 {
30+ if (auth ()->loggedIn ()) {
31+ return redirect ()->to (config ('Auth ' )->registerRedirect ());
32+ }
33+
3034 // Check if registration is allowed
3135 if (! setting ('Auth.allowRegistration ' )) {
3236 return redirect ()->back ()->withInput ()
Original file line number Diff line number Diff line change 1111use CodeIgniter \Test \FeatureTestTrait ;
1212use Config \Services ;
1313use Tests \Support \DatabaseTestCase ;
14+ use Tests \Support \FakeUser ;
1415
1516/**
1617 * @internal
1718 */
1819final class RegisterTest extends DatabaseTestCase
1920{
2021 use FeatureTestTrait;
22+ use FakeUser;
2123
2224 protected $ namespace ;
2325
@@ -146,6 +148,18 @@ public function testRegisterRedirectsToActionIfDefined(): void
146148 ]);
147149 }
148150
151+ public function testRegisterRedirectsIfLoggedIn (): void
152+ {
153+ // log them in
154+ session ()->set ('user ' , ['id ' => $ this ->user ->id ]);
155+
156+ $ result = $ this ->withSession ()->get ('/register ' );
157+
158+ $ result ->assertStatus (302 );
159+ $ result ->assertRedirect ();
160+ $ result ->assertRedirectTo (config ('Auth ' )->registerRedirect ());
161+ }
162+
149163 protected function setupConfig (): void
150164 {
151165 $ config = config ('Validation ' );
You can’t perform that action at this time.
0 commit comments