kdyby/facebook user variable

Notice: This thread is very old.
speedees
Member | 8
+
0
-

Hello,

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.

Thanks!

David Matějka
Moderator | 6445
+
+1
-

It is Nette\Security\User object representing the current user, see the doc: https://doc.nette.org/…thentication

speedees
Member | 8
+
0
-

David Matějka wrote:

It is Nette\Security\User object 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?

Azathoth
Member | 495
+
0
-

Nette\Security\User is service providing login, logout, and other methods.
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.

tomcat4x
Member | 22
+
+1
-

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.

speedees
Member | 8
+
0
-

Thank you all for the answers.
It's much more clear for me now.