Email verified field in user claims returns integer value if the `user_email_verification` field has value.

Created on 19 August 2024, 4 months ago
Updated 11 September 2024, 3 months ago

Problem

what is happening is user_email_verification config if has a value this function variable_get() just returns the value as it is in the database and php stores boolean values as for true it is 1 for false it is 0 .. so for users who are either approved by admin or do not require user email verification in this case the above function return a default value which is set to TRUE but if any user whose needs and had user_email_verification field value set returns a raw value as 1 for true and 0 for false.

Steps to reproduce

Step 1: Try to authenticate with a user having verified his account by email and the oauth client expecting the user info as below :

{
  "sub": "1",
  "email": "sankettejas@gmail.com",
  "email_verified": 1,
  "name": "admin",
  "preferred_username": "admin",
  "zoneinfo": "Asia/Kolkata",
  "given_name": null,
  "family_name": null,
  "roles": [
    "authenticated user",
    "administrator"
  ]
}

throws an error saying expected boolean received integer for a field.

Proposed resolution

Wrapping the below code at

  if (in_array('email', $requested_scopes)) {
      $claims['email'] = $account->mail;
      $claims['email_verified'] = variable_get('user_email_verification', TRUE);
    }

to

  if (in_array('email', $requested_scopes)) {
      $claims['email'] = $account->mail;
      $claims['email_verified'] = boolval(variable_get('user_email_verification', TRUE));
    }

with boolval() php to return boolean value should help resolve this.

🐛 Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

🇮🇳India tdnshah

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024