But $client->getUserAttributes() does not return the correct values and if i remove the validation condition the user is created without username, mail, etc.
Regarding validation, the built-in validation rules are for local registrations. If you want to add in automatic registrations using facebook/twitter/etc data, you might want to create a new scenario with corresponding validation rules. Something like $user->setScenario("register-external").
The problem with external authentication, though, is that different services will give you different data. For example, you may get email+username from facebook, but you’ll only get username from twitter (no email). You need to run through the code and see exactly what data you get from the services you need, then you can come up with a solution on how to process them.
Not sure what you meant by this … The only dependency I see is curl.
That is a helper function to make the module more extendable.
When you configure the module in config/web.php, you have the option of setting the modelClasses property. The \amnah\yii2\user\Module::model($name, $config=[]) function uses that modelClasses property to create the corresponding model.
For example:
// config/web.php
'modules' => [
'user' => [
// ...
'modelClasses' => [
'Profile' => 'app\models\MyProfile',
],
// ...
],
],
//so these two are equivalent
$profile = Yii::$app->getModule("user")->model("Profile");
$profile = new \app\models\MyProfile();
// though technically, it does it via Yii::createObject(), so you can pass in
// a config array for the object properties
$profile = Yii::$app->getModule("user")->model("Profile", ["property1"=>"value1"]);