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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tdnshah created an issue. See original summary.

tdnshah’s picture

Status: Active » Needs review
tdnshah’s picture

Assigned: tdnshah » Unassigned
keshavv’s picture

Status: Needs review » Reviewed & tested by the community

  • cafuego committed a3a53328 on 7.x-1.x authored by tdnshah
    Issue #3468873 by tdnshah Email verified field in user claims returns...
tdnshah’s picture

@cafuego Can we closed this issue if it has been committed ?

cafuego’s picture

Status: Reviewed & tested by the community » Fixed

We can, I forgot to set the issue to fixed so the site didn't auto-close it. D'oh!

cafuego’s picture

cafuego’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.