- Issue created by @solideogloria
- Merge request !172fix: re-add is_new flag to $context obj and hook_openid_connect_post_authorize → (Open) created by baikho
See the following code in OpenIDConnect::completeAuthorization
$account = $this->createUser($context['sub'], $context['userinfo'], $client->id());
...
// Store the newly created account.
$this->saveUserinfo($account, $context + ['is_new' => TRUE]);
...
$this->moduleHandler
->invokeAll('openid_connect_post_authorize', [$account, $context]);
The 'is_new' => TRUE
is added to the context when calling saveUserinfo
, which allows implementations of hook_openid_connect_userinfo_save
to know if the account was just created or not.
$account->isNew()
would return FALSE
, since it has already been saved, so this is very helpful information to have in the context. However, the information is not passed to the hook_openid_connect_post_authorize
invocation, as you can see above. I am trying to determine in my hook implementation if the account was just created or not, and I don't see an easy way built-in. It would be nice to have in the $context
.
Implement hook_openid_connect_post_authorize
, then authenticate for the first time so that an account is created. The post authorize hook will not have a way to know if the account was authenticating for the first time, or the hundredth time.
Something like this?
$account = $this->createUser($context['sub'], $context['userinfo'], $client->id());
$context += ['is_new' => $is_new];
...
// Store the newly created account.
$this->saveUserinfo($account, $context);
...
$this->moduleHandler
->invokeAll('openid_connect_post_authorize', [$account, $context]);
Active
3.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.