- πΊπΈUnited States DamienMcKenna NH, USA
Should this be a documentation task, or should there be an option in the UI (and/or Drush commands) to perform these tasks?
How can we programmatically enable cas for all existing users?
Created a hook_user_presave(EntityInterface $user)
for this. First, a select query for authmap
table to see if uid exits. If uid not in the table, use an insert query to add.
If I manually run the query it works and cas is enabled for the user:
INSERT INTO authmap(`provider`, `data`, `uid`, `authname`) VALUES ('cas','N;',uid,username)
If I try out either of the following queries it does not inserts the values into the authmap
table:
//values for uid and username are correct
$userID = $user->id();
$userName = $user->getAccountName();
$query = \Drupal::database()->insert('authmap')
->fields(['uid', 'provider', 'authname', 'data'])
->values([
'uid' => $userID,
'provider' => 'cas',
'authname' => $userName,
'data' => 'N;',
])
->execute();
$query = \Drupal::database()->insert('authmap');
$query->fields([
'uid',
'provider',
'authname',
'data'
]);
$query->values([
$userID,
'cas',
$userName,
'N;'
]);
$query->execute();
Active
2.0
CAS
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Should this be a documentation task, or should there be an option in the UI (and/or Drush commands) to perform these tasks?