# MultiAuth Login via Custom Finder in Cake3 - How?

**URL:** <https://discourse.cakephp.org/t/multiauth-login-via-custom-finder-in-cake3-how/145>\
**Category:** Need Help\
**Created:** [April 26, 2016, 12:34am UTC](https://discourse.cakephp.org/t/multiauth-login-via-custom-finder-in-cake3-how/145 "2016-04-26T00:34:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ali](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/ali/32/123_2.png) [@ali](https://discourse.cakephp.org/u/ali)\
**Post date:** [April 26, 2016, 12:34am UTC](https://discourse.cakephp.org/t/multiauth-login-via-custom-finder-in-cake3-how/145/1 "2016-04-26T00:34:46Z")

</div>

The goal is to give users the ability to login with multiple fields, such as email or username.

I’ve heard that this can be achieved with [Custom Finder Methods](http://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#custom-finder-methods) in CakePHP 3. But I can’t figure out how this is supposed to work…

Has anyone achieved this or knows another way? The plugins I originally intended to use for it say Custom Finders are the way to go, but I could find no further info on that topic.

---

<div class="post-metadata">

**Author:** ![ADmad](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/admad/32/20_2.png) [@ADmad](https://discourse.cakephp.org/u/ADmad)\
**Post date:** [April 26, 2016, 8:54am UTC](https://discourse.cakephp.org/t/multiauth-login-via-custom-finder-in-cake3-how/145/2 "2016-04-26T08:54:55Z")

</div>

Wait for this PR to be merged [https://github.com/cakephp/cakephp/pull/8704](https://github.com/cakephp/cakephp/pull/8704)

---

<div class="post-metadata">

**Author:** ![ADmad](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/admad/32/20_2.png) [@ADmad](https://discourse.cakephp.org/u/ADmad)\
**Post date:** [April 28, 2016, 11:53am UTC](https://discourse.cakephp.org/t/multiauth-login-via-custom-finder-in-cake3-how/145/3 "2016-04-28T11:53:57Z")

</div>

The PR mentioned above has been merged and will be available in 3.2.9 release. You can use the master branch if you need it right away 🙂

---

<div class="post-metadata">

**Author:** ![ali](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/ali/32/123_2.png) [@ali](https://discourse.cakephp.org/u/ali)\
**Post date:** [May 23, 2016, 1:47pm UTC](https://discourse.cakephp.org/t/multiauth-login-via-custom-finder-in-cake3-how/145/4 "2016-05-23T13:47:22Z")

</div>

Thanks for the info ADmad!

For everyone else to whom it’s not entirely clear how to implement this feature, here’s a quick how-to:

1. Make sure you have CakePHP 3.2.9 installed.

2. To the configuration of the Auth component, add:

3. Then to your UsersTable add:

$options[‘username’] contains whatever was typed into the form, whether an email or the username.

Hopefully this will be of some use, since the way it works is not immediately obvious.
