I am Nette beginner and trying to implement Kdyby/Facebook authentication.
In Kdyby/Facebook API in the Authentication section with the code example.
At the very end the method
$this->user->login is being called.
My question is, where is this ‘user’ came from? Should that be implemented somewhere inside of UsersModel.
David Matějka wrote:
Nette\Security\Userobject representing the current user, see the doc: https://doc.nette.org/…thentication
Thank you, David!
I understand that it's an object representing the current user.
My question is, where was the instance $this->user initiated?
Because I thought that before the FB authentication every information about user is empty. And within the FB user authentication we are trying to create an object about the current user. But how come we can during the FB authentication ask for $this->user when it was not initiated/authenticated yet?
So again, should the $this->user be initiated within UsersModel – atribute of LoginPresenter?
- Member | 495
Nette\Security\User is service providing login, logout, and other
If you want to get information about user, who signed in through facebook, you have to call $this->user->identity, which holds data about signed in user.
Maybe it is confusing, because it looks like $this->user is instance of signed in user, but in fact, $this->user->identity is propably, what you search for.
- Member | 22
You do not need to worry about instancing the user class.
It is automatically done by the framework and you can access it over the property $user in every presenter.
The user Object is all the time there. Its up to you to fill it with information if a user logs in for example over a form. If the user is not logged in it is an “anonymous” user for the framework.