Where does the authenticator file go?

Bill Lions
Member | 47
+
0
-

I am reading the custom authenticator example on https://doc.nette.org/…thentication

Where does this file go?
What does it need to be called?

Thanks
Bill Lions

manwe
Member | 44
+
+2
-

Hey Bill!

  1. Basically, it does not matter where you put it, since Nette uses Finder to find all needed files. It just needs to be in app/ folder.
  2. You can call it whatever you want, you just need to make sure it implements Nette\Security\IAuthenticator
  3. Register it in your config.neon file as a service, Nette will take care of the rest.

Last edited by manwe (2019-03-20 08:03)

Bill Lions
Member | 47
+
0
-

Thanks,

That worked.. mostly
Do I need to 'use NSI\IAuthenticator or something?

Fatal Error

Interface 'NS\IAuthenticator' not found
manwe
Member | 44
+
+2
-

use Nette\Security\IAuthenticator instead of NS – NS is just an alias for Nette\Security used in the example.

(you can “rename” namespace by using
use Nette\Security as NS; at the beginning of your file
)

Last edited by manwe (2019-03-20 09:39)

Bill Lions
Member | 47
+
+1
-

Thanks, also, the example only works when

public function __construct(Nette\Database\Connection $database)

is changed to context

public function __construct(Nette\Database\Context $database)
CZechBoY
Member | 3608
+
+1
-

@BillLions Can you send fix via PR? In top part of page, there is “Improve this page” link.

Bill Lions
Member | 47
+
0
-

Looks like somebody has beat me to it.
The fix is already in, not yet live.