# Cake 4 Authentication Plugin with Admin Prefix

**URL:** <https://discourse.cakephp.org/t/cake-4-authentication-plugin-with-admin-prefix/11314>\
**Category:** Plugins\
**Tags:** help\
**Created:** [July 1, 2023, 10:33pm UTC](https://discourse.cakephp.org/t/cake-4-authentication-plugin-with-admin-prefix/11314 "2023-07-01T22:33:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![devtun](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@devtun](https://discourse.cakephp.org/u/devtun)\
**Post date:** [July 1, 2023, 10:33pm UTC](https://discourse.cakephp.org/t/cake-4-authentication-plugin-with-admin-prefix/11314/1 "2023-07-01T22:33:44Z")

</div>

Hi, I am using Authentication plugin 2.0 with cake 4. When I try to login directly from [www.project.com/login](http://www.project.com/login) there is not problem.  
But trying to login with my Admin prefix  
[www.project.com/Admin/login](http://www.project.com/Admin/login)  
I get error  
“Call to a member function allowUnauthenticated() on null”

my route:

$routes-\>scope (‘/’, function (RouteBuilder $builder) {  
$builder-\>prefix( ‘admin’, function (RouteBuilder $routes) {  
$routes-\>connect(‘/’, [‘controller’ =\> ‘Users’, ‘action’ =\> ‘login’]);  
$routes-\>connect(‘/users/{id}/_‘, [‘controller’ =\> ‘Users’, ‘action’ =\> ‘login’]);  
$routes-\>connect(’/:controller/:action/_’, );  
$routes-\>fallbacks(DashedRoute::class);  
}  
);

```
     $builder->scope('/admin', function (RouteBuilder $routes) {
            $routes->loadPlugin('Authentication');
        });

```

});

How can I configure the Authentication plugin to work with Admin Prefix please.  
Thanks for helping

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [July 2, 2023, 2:29pm UTC](https://discourse.cakephp.org/t/cake-4-authentication-plugin-with-admin-prefix/11314/2 "2023-07-02T14:29:46Z")

</div>

None of the code you’ve shown is trying to call `allowUnauthenticated`. Where is that call happening?
