File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ Example of configuring the authentication middleware using ``authentication`` ap
4545 public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
4646 {
4747 $service = new AuthenticationService();
48+ $service->setConfig([
49+ 'unauthenticatedRedirect' => '/users/login',
50+ 'queryParam' => 'redirect',
51+ ]);
4852
4953 $fields = [
5054 'username' => 'email',
@@ -128,7 +132,18 @@ like::
128132 }
129133 }
130134
131- Then add a simple logout action::
135+ Make sure that you whitelist the ``login `` action in your controller's
136+ ``beforeFilter() `` callback as mentioned in the previous section, so that
137+ unauthenticated users are able to access it::
138+
139+ public function beforeFilter(\Cake\Event\EventInterface $event)
140+ {
141+ parent::beforeFilter($event);
142+
143+ $this->Authentication->allowUnauthenticated(['login']);
144+ }
145+
146+ and then add a simple logout action::
132147
133148 public function logout()
134149 {
You can’t perform that action at this time.
0 commit comments