Jelajahi Sumber

Added default scopes to read e-mail

Edgard 6 tahun lalu
induk
melakukan
94a030a790
1 mengubah file dengan 9 tambahan dan 2 penghapusan
  1. 9 2
      inc/provider.class.php

+ 9 - 2
inc/provider.class.php

@@ -359,19 +359,26 @@ class PluginSinglesignonProvider extends CommonDBTM {
     * @return \League\OAuth2\Client\Provider\AbstractProvider
     * @return \League\OAuth2\Client\Provider\AbstractProvider
     */
     */
    public static function createInstance($type = 'generic', array $options = array(), array $collaborators = array()) {
    public static function createInstance($type = 'generic', array $options = array(), array $collaborators = array()) {
+
+      if (!isset($options['scope'])) {
+         $options['scope'] = [];
+      }
+
       switch ($type) {
       switch ($type) {
          case 'facebook':
          case 'facebook':
             if (!isset($options['graphApiVersion'])) {
             if (!isset($options['graphApiVersion'])) {
-               $options['graphApiVersion'] = 'v2.8';
+               $options['graphApiVersion'] = 'v2.12';
             }
             }
             return new League\OAuth2\Client\Provider\Facebook($options, $collaborators);
             return new League\OAuth2\Client\Provider\Facebook($options, $collaborators);
          case 'github':
          case 'github':
+            $options['scope'][] = 'user:email';
             return new League\OAuth2\Client\Provider\Github($options, $collaborators);
             return new League\OAuth2\Client\Provider\Github($options, $collaborators);
          case 'google':
          case 'google':
             return new League\OAuth2\Client\Provider\Google($options, $collaborators);
             return new League\OAuth2\Client\Provider\Google($options, $collaborators);
          case 'instagram':
          case 'instagram':
             return new League\OAuth2\Client\Provider\Instagram($options, $collaborators);
             return new League\OAuth2\Client\Provider\Instagram($options, $collaborators);
          case 'linkedin':
          case 'linkedin':
+            $options['scope'][] = 'r_emailaddress';
             return new League\OAuth2\Client\Provider\LinkedIn($options, $collaborators);
             return new League\OAuth2\Client\Provider\LinkedIn($options, $collaborators);
          case 'generic':
          case 'generic':
          default:
          default:
@@ -513,7 +520,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
       //First: check linked user
       //First: check linked user
 
 
       $email = false;
       $email = false;
-      $email_fields = array('email', 'e-mail');
+      $email_fields = array('email', 'e-mail', 'email-address');
 
 
       foreach ($email_fields as $field) {
       foreach ($email_fields as $field) {
          if (isset($resource_array[$field]) && is_string($resource_array[$field])) {
          if (isset($resource_array[$field]) && is_string($resource_array[$field])) {