# Login with cakedc users gives me exception on cakephp 4.2

**URL:** <https://discourse.cakephp.org/t/login-with-cakedc-users-gives-me-exception-on-cakephp-4-2/10286>\
**Category:** Need Help\
**Created:** [April 7, 2022, 6:30pm UTC](https://discourse.cakephp.org/t/login-with-cakedc-users-gives-me-exception-on-cakephp-4-2/10286 "2022-04-07T18:30:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [April 7, 2022, 6:30pm UTC](https://discourse.cakephp.org/t/login-with-cakedc-users-gives-me-exception-on-cakephp-4-2/10286/1 "2022-04-07T18:30:33Z")

</div>

Is giving me the error of " in\_array() expects parameter 2 to be array, bool given", the reason is that the function class\_implements() is giving me an error with the class passed as argument and is returning false instead of an array.  
It happens with the two-factor authentication, when is trying to see if that class implements an interface, but the class\_implements() function doesn’t find the class passed as argument, is there a way to disable two-factor authentication?

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [April 8, 2022, 6:11pm UTC](https://discourse.cakephp.org/t/login-with-cakedc-users-gives-me-exception-on-cakephp-4-2/10286/2 "2022-04-08T18:11:59Z")

</div>

A full stacktrace of your error would be usefull for us to provide you better help because the error `in_array() expects parameter 2 to be array, bool given` can’t be associated with a specific problem.

Can you explain

- what you already did?
- what versions you are using?
- what did you change so its not working anymore (if it worked before)?

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [April 9, 2022, 3:53pm UTC](https://discourse.cakephp.org/t/login-with-cakedc-users-gives-me-exception-on-cakephp-4-2/10286/3 "2022-04-09T15:53:41Z")

</div>

I installed cakedc users in my site, it gives me the error when I try to login with superuser, I am using cakedc users 9.  
This is the screenshot of the error in the site:

 ![trace](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/c/c2ae255bc208c0e91b13a9798a3baf362fc39d39.png)

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [April 9, 2022, 4:09pm UTC](https://discourse.cakephp.org/t/login-with-cakedc-users-gives-me-exception-on-cakephp-4-2/10286/4 "2022-04-09T16:09:07Z")

</div>

if you copied the `users.php` from the the repository to your `config/users.php` then make sure you are on the correct version of that file.

Especially that line is needed because this is was causing your error.

> <https://github.com/CakeDC/users/blob/9.3.0/config/users.php#L125>

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [April 9, 2022, 5:27pm UTC](https://discourse.cakephp.org/t/login-with-cakedc-users-gives-me-exception-on-cakephp-4-2/10286/5 "2022-04-09T17:27:35Z")

</div>

I added the Webauthn2fa in cakedc/users/config/users.php, but now is trying to enter the site from the Authentication plugin, not the cakedc users, and is giving me an exception of “Call to a member function getResult() on null”.  
What do I have to change so that it logins with cakedc users and not Authentication plugin?  
This is the screenshot:

 ![getResult](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/3/3a42a253545252d3c81f9a78271afca993027d1e.png)

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [April 9, 2022, 5:54pm UTC](https://discourse.cakephp.org/t/login-with-cakedc-users-gives-me-exception-on-cakephp-4-2/10286/6 "2022-04-09T17:54:28Z")

</div>

You definitely should not edit any files present in `vendor` so if it wasn’t present in there you are not on CakeDC/Users version 9.3

Make sure you are on the latest version via `composer update -W`

Your error above means that the Authentication Component hasn’t been loaded.  
Did you add

```auto
public function initialize(): void {
    $this->loadComponent('CakeDC/Users.Setup');
}

```

in your `src/Controller/AppController.php`?

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [April 9, 2022, 6:23pm UTC](https://discourse.cakephp.org/t/login-with-cakedc-users-gives-me-exception-on-cakephp-4-2/10286/7 "2022-04-09T18:23:33Z")

</div>

Thank you now is working.  
How can I get the getresult()-\>isvalid() with cakedc users?

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [April 9, 2022, 6:36pm UTC](https://discourse.cakephp.org/t/login-with-cakedc-users-gives-me-exception-on-cakephp-4-2/10286/8 "2022-04-09T18:36:28Z")

</div>

Since you now have access to the AuthenticationComponent inside your controllers just use

```auto
$this->Authentication->getResult()->isValid();

```

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [April 9, 2022, 6:46pm UTC](https://discourse.cakephp.org/t/login-with-cakedc-users-gives-me-exception-on-cakephp-4-2/10286/9 "2022-04-09T18:46:59Z")

</div>

Yes, thank you, now is working
