public function CasUserManager::register in CAS 8
Same name and namespace in other branches
- 2.x src/Service/CasUserManager.php \Drupal\cas\Service\CasUserManager::register()
Register a local Drupal user given a CAS username.
Parameters
string $authname: The CAS username.
array $property_values: Property values to assign to the user on registration.
string $local_username: The local Drupal username to be created.
Return value
\Drupal\user\UserInterface The user entity of the newly registered user.
Throws
\Drupal\cas\Exception\CasLoginException When the user account could not be registered.
1 call to CasUserManager::register()
- CasUserManager::login in src/
Service/ CasUserManager.php - Attempts to log the user in to the Drupal site.
File
- src/
Service/ CasUserManager.php, line 154
Class
- CasUserManager
- Class CasUserManager.
Namespace
Drupal\cas\ServiceCode
public function register($authname, array $property_values = [], $local_username = NULL) {
if (!$local_username) {
@trigger_error('Calling CasUserManager::register() without the $local_username argument is deprecated in cas:8.x-1.6 and the $local_username argument will be required in cas:8.x-2.0.', E_USER_DEPRECATED);
$local_username = $authname;
}
$property_values['name'] = $local_username;
$property_values['pass'] = $this
->randomPassword();
try {
$user = $this->externalAuth
->register($authname, $this->provider, $property_values);
} catch (ExternalAuthRegisterException $e) {
throw new CasLoginException($e
->getMessage(), CasLoginException::USERNAME_ALREADY_EXISTS);
}
return $user;
}