Commit e4c846a6 authored by jcnventura's avatar jcnventura Committed by Joao Ventura
Browse files

Issue #3154326 by jcnventura: Simplify OpenIDConnect::extractSub()

parent 7f365c50
......@@ -202,16 +202,15 @@ class OpenIDConnect {
* The sub, or FALSE if there was an error.
*/
public function extractSub(array $user_data, array $userinfo) {
if (!isset($user_data['sub']) && !isset($userinfo['sub'])) {
return FALSE;
}
elseif (!isset($user_data['sub'])) {
return $userinfo['sub'];
if (isset($user_data['sub'])) {
// If we have sub in both $user_data and $userinfo, return FALSE if they
// differ. Otherwise return the one in $user_data.
return (!isset($userinfo['sub']) || ($user_data['sub'] == $userinfo['sub'])) ? $user_data['sub'] : FALSE;
}
elseif (isset($userinfo['sub']) && $user_data['sub'] != $userinfo['sub']) {
return FALSE;
else {
// No sub in $user_data, return from $userinfo if it exists.
return (isset($userinfo['sub'])) ? $userinfo['sub'] : FALSE;
}
return $user_data['sub'];
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment