Skip to content

Commit b80a184

Browse files
committed
Merge branch 'rtconner/9.x' into 9.x
2 parents 0049211 + 5f97f82 commit b80a184

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Illuminate/Auth/GuardHelpers.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ public function setUser(AuthenticatableContract $user)
9595
return $this;
9696
}
9797

98+
/**
99+
* Forget the current user.
100+
*
101+
* @return $this
102+
*/
103+
public function forgetUser()
104+
{
105+
$this->user = null;
106+
107+
return $this;
108+
}
109+
98110
/**
99111
* Get the user provider used by the guard.
100112
*

tests/Auth/AuthGuardTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,14 @@ public function testLoginOnceFailure()
588588
$this->assertFalse($guard->once(['foo']));
589589
}
590590

591+
public function testForgetUserSetsUserToNull()
592+
{
593+
$user = m::mock(Authenticatable::class);
594+
$guard = $this->getGuard()->setUser($user);
595+
$guard->forgetUser();
596+
$this->assertNull($guard->getUser());
597+
}
598+
591599
protected function getGuard()
592600
{
593601
[$session, $provider, $request, $cookie, $timebox] = $this->getMocks();

0 commit comments

Comments
 (0)