Skip to content

Commit b722f40

Browse files
committed
Redirect home when already logged in
1 parent dd51c75 commit b722f40

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Controllers/StageFrontController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class StageFrontController extends Controller
1414
*/
1515
public function create()
1616
{
17+
if (session('stagefront.unlocked') === true) {
18+
return redirect('/');
19+
}
20+
1721
$liveSite = config('stagefront.live_site');
1822

1923
if ($liveSite) {

tests/Feature/StageFrontTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ public function it_does_not_allow_access_when_you_provide_invalid_credentials()
8484
->assertSessionHasErrors('password');
8585
}
8686

87+
/** @test */
88+
public function it_redirects_home_if_you_are_already_logged_in()
89+
{
90+
$this->enableStageFront();
91+
92+
session()->put('stagefront.unlocked', true);
93+
94+
$this->get($this->url)->assertRedirect('/');
95+
}
96+
8797
/** @test */
8898
public function the_password_may_be_stored_encrypted()
8999
{

0 commit comments

Comments
 (0)