Skip to content
Snippets Groups Projects
Commit 835b68eb authored by Matthew Slater's avatar Matthew Slater
Browse files

drupal 10 compatibility fix

parent aaf79f33
No related branches found
No related tags found
No related merge requests found
core: "8.x"
api: 2
projects:
token:
type: "module"
version: "1.5"
...@@ -84,7 +84,7 @@ function alt_login_form_alter(&$form, $form_state, $form_id) { ...@@ -84,7 +84,7 @@ function alt_login_form_alter(&$form, $form_state, $form_id) {
if (empty($user_aliases['username'])) { if (empty($user_aliases['username'])) {
$namefield['#access'] = FALSE; $namefield['#access'] = FALSE;
if ($user->isNew()) { if ($user->isNew()) {
$namefield['#value'] = user_password(8); $namefield['#value'] = \Drupal::service('password_generator')->generate(8);
} }
elseif (count($user_aliases) == 1) { elseif (count($user_aliases) == 1) {
$labels = \Drupal::service('alt_login.method_manager')->getActiveLabels(); $labels = \Drupal::service('alt_login.method_manager')->getActiveLabels();
......
...@@ -19,7 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -19,7 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* *
* @AltLoginMethod( * @AltLoginMethod(
* id = "address_name", * id = "address_name",
* label = @Translation("Full name"), * label = @Translation("Address firstname + lastname"),
* description = @Translation("The given name and family name from the address field. Warning, duplicate names could lead to login and other confusions.") * description = @Translation("The given name and family name from the address field. Warning, duplicate names could lead to login and other confusions.")
* ) * )
*/ */
...@@ -48,6 +48,11 @@ class AddressName implements AltLoginMethodInterface, ContainerFactoryPluginInte ...@@ -48,6 +48,11 @@ class AddressName implements AltLoginMethodInterface, ContainerFactoryPluginInte
*/ */
private $entityTypeManager; private $entityTypeManager;
/**
* @var MessengerInterface
*/
private $messenger;
/** /**
* @param EntityFieldManagerInterface $entity_field_manager * @param EntityFieldManagerInterface $entity_field_manager
* @param Connection $database * @param Connection $database
...@@ -137,15 +142,15 @@ class AddressName implements AltLoginMethodInterface, ContainerFactoryPluginInte ...@@ -137,15 +142,15 @@ class AddressName implements AltLoginMethodInterface, ContainerFactoryPluginInte
return $this->fieldName; return $this->fieldName;
} }
/**
* {@inheritdoc}
*/
private function getUids($alias) { private function getUids($alias) {
$fname = $this->fieldName(); $fname = $this->fieldName();
$table = 'user__'.$fname; $query = $this->database
$query = $this->database->select($table, 'u') ->select('user__'.$fname, 'u')
->fields('u', ['entity_id']) ->fields('u', ['entity_id'])
->where( ->where("CONCAT_WS(' ', {$fname}_given_name, {$fname}_family_name) = '$alias'");
"CONCAT_WS(:space, {$fname}_given_name, {$fname}_family_name) ='".$alias."'",
[':space' => ' ']
);
// Hopefully the database field isn't case sensitive. // Hopefully the database field isn't case sensitive.
return $query->execute()->fetchCol(); return $query->execute()->fetchCol();
} }
......
...@@ -25,7 +25,7 @@ class Settings extends ConfigFormBase { ...@@ -25,7 +25,7 @@ class Settings extends ConfigFormBase {
$config = $this->config('alt_login.settings'); $config = $this->config('alt_login.settings');
$form['aliases'] = [ $form['aliases'] = [
'#title' => $this->t('Allow login with'), '#title' => $this->t('Allow login with'),
'#description' => $this->t('Unchecking the username prevents its use for logging in.'), '#description' => $this->t('Unchecking the username prevents its use for logging in, and hides the username field from the user form.'),
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#options' => \Drupal::service('alt_login.method_manager')->getOptions(), '#options' => \Drupal::service('alt_login.method_manager')->getOptions(),
'#default_value' => (array)$config->get('aliases'), '#default_value' => (array)$config->get('aliases'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment