Where does the authenticator file go?

about a month ago

Bill Lions
Member | 19
+
0
-

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

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

Thanks
Bill Lions

about a month ago

manwe
Member | 39
+
+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)

about a month ago

Bill Lions
Member | 19
+
0
-

Thanks,

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

Fatal Error

Interface 'NS\IAuthenticator' not found

about a month ago

manwe
Member | 39
+
+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)

about a month ago

Bill Lions
Member | 19
+
+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)

about a month ago

CZechBoY
Member | 3334
+
+1
-

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

about a month ago

Bill Lions
Member | 19
+
0
-

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