File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ public function registerView()
4545 */
4646 public function registerAction (): RedirectResponse
4747 {
48+ if (auth ()->loggedIn ()) {
49+ return redirect ()->to (config ('Auth ' )->registerRedirect ());
50+ }
51+
4852 // Check if registration is allowed
4953 if (! setting ('Auth.allowRegistration ' )) {
5054 return redirect ()->back ()->withInput ()
Original file line number Diff line number Diff line change @@ -160,6 +160,23 @@ public function testRegisterRedirectsIfLoggedIn(): void
160160 $ result ->assertRedirectTo (config ('Auth ' )->registerRedirect ());
161161 }
162162
163+ public function testRegisterActionRedirectsIfLoggedIn (): void
164+ {
165+ // log them in
166+ session ()->set ('user ' , ['id ' => $ this ->user ->id ]);
167+
168+ $ result = $ this ->withSession ()->post ('/register ' , [
169+ 'username ' => 'JohnDoe ' ,
170+ 171+ 'password ' => 'secret things might happen here ' ,
172+ 'password_confirm ' => 'secret things might happen here ' ,
173+ ]);
174+
175+ $ result ->assertStatus (302 );
176+ $ result ->assertRedirect ();
177+ $ result ->assertRedirectTo (config ('Auth ' )->registerRedirect ());
178+ }
179+
163180 protected function setupConfig (): void
164181 {
165182 $ config = config ('Validation ' );
You can’t perform that action at this time.
0 commit comments