I just had a chance to try the yii2-authclient extension with Facebook. It works beautifully. I had one minor change I had to make.
$password = Yii::$app->security->generateRandomString(6); $user = new User([ 'username' => $attributes['login'], 'email' => $attributes['email'], 'password' => $password, ]);
It was throwing an error becaus it did not recognize ‘login’, so I simply substituted ‘name’ in there and it works perfectly. Also, the supplied SQL in the guide lists data-type as string and that didn’t work for me, had to change it varchar. I’m using MySql. Also, I didnt’ see the point of:
It was setting the token with each registration, so I just commented that out. Anyway, those were very minor hiccups.
So facebook login and create user implemented in about 20 minutes, and I was slow because I had to match datatypes to get my foreign key to work correctly, which took me a while to figure out that I had it wrong. So in reality, this is a 10 minute implementation at most.
Anyway, the guide has supplied clear directions that work. Everything from composer install to config to site controller methods went smoothly. The widget is cool and obviously incredibly easy to work with in the view.
This is a perfect starting implementation for something that almost every client is going to demand for their projects. This is awesome guys, a wonderful feature, and another reason to love Yii 2.