Skip to content

Commit

Permalink
Add redirectPath method
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperLaiTW committed Jun 2, 2017
1 parent 90ea4cf commit becc8a5
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/LoginUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@
*/
trait LoginUsers
{
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/';

/**
* Create a new controller instance.
*
Expand Down Expand Up @@ -48,7 +41,7 @@ public function login()

Auth::login($user);

return redirect(session('url.intended', $this->redirectTo));
return redirect(session('url.intended', $this->redirectPath()));
}

/**
Expand All @@ -67,4 +60,14 @@ public function logout(Request $request)

return redirect('/');
}

/**
* Get the post register / login redirect path.
*
* @return string
*/
private function redirectPath()
{
return property_exists($this, 'redirectTo') ? $this->redirectTo : '/';
}
}

0 comments on commit becc8a5

Please sign in to comment.