protected function AuthController::createDrupalUser in Auth0 Single Sign On 8
Same name and namespace in other branches
- 8.2 src/Controller/AuthController.php \Drupal\auth0\Controller\AuthController::createDrupalUser()
Create the Drupal user based on the Auth0 user profile.
1 call to AuthController::createDrupalUser()
- AuthController::signupUser in src/
Controller/ AuthController.php - Create or link a new user based on the auth0 profile.
File
- src/
Controller/ AuthController.php, line 478
Class
- AuthController
- Controller routines for auth0 authentication.
Namespace
Drupal\auth0\ControllerCode
protected function createDrupalUser($userInfo) {
$user = User::create();
$user
->setPassword($this
->generatePassword(16));
$user
->enforceIsNew();
if (isset($userInfo['email']) && !empty($userInfo['email'])) {
$user
->setEmail($userInfo['email']);
}
else {
$user
->setEmail("change_this_email@" . uniqid() . ".com");
}
// If the username already exists, create a new random one.
$username = $userInfo['nickname'];
if (user_load_by_name($username)) {
$username .= time();
}
$user
->setUsername($username);
$user
->activate();
$user
->save();
return $user;
}