Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-59115

OAuth2 does not pass in all user mapped settings into new account

    XMLWordPrintable

Details

    • MOODLE_311_STABLE, MOODLE_33_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE
    • MOODLE_311_STABLE_MDL-59115
    • master_MDL-59115
    • Hide

      case 1 - E-mail confirmation required: 

      1. Enable OAuth2 authentication plugin (Site administration > plugins > manage authentication)
      2. Set up an OAuth2 issuer
        1. Setting up OAuth2 can be tricky, it is recommended to review the documentation here: https://docs.moodle.org/311/en/OAuth_2_services)
        2. Setup a Microsoft provider, using the guide here: https://docs.moodle.org/311/en/OAuth_2_Microsoft_service (It doesn't have to be MS, but it is one of the easier ones to setup, and it allows "localhost")
      3. Set up field mappings for the following fields: 
        Note: Depending on what data you set on the provider side there might not be enough fields "sent" to Moodle to map to all available user profile fields. Another option is to start with the default fields and then after testing map the data from the provider to other Moodle user profile fields. For example take the country field from the provider and map it to the "idnumber" field in Moodle
        1. firstname
        2. lastname
        3. city
        4. country
        5. lang
        6. description
        7. url
        8. idnumber
        9. institution
        10. department
        11. phone1
        12. phone2
        13. firstnamephonetic
        14. lastnamephonetic
        15. middlename
        16. alternatename
        17. username
      4. Log in with OAuth2
      5. Confirm the user
        Either log into the Moodle instance as a site administrator and confirm the user from the user overview page (Site administration > Users > Browse list of users) OR
        If the test site can send emails then the test user will receive a confirmation email when they first log in. In this case click the link in the email.
      6. Log in with OAuth2 
      7. Go to Profile / Edit Profile
      8. On the Edit profile page you should see all the mapped and sent values. 

      case 2 E-mail confirmation is not required: 

      1. Enable OAuth2 authentication plugin (Site administration > plugins > manage authentication)
      2. Set up an OAuth2 issuer
      3. Set up field mappings for the following fields: 
        1. firstname
        2. lastname
        3. city
        4. country
        5. lang
        6. description
        7. url
        8. idnumber
        9. institution
        10. department
        11. phone1
        12. phone2
        13. firstnamephonetic
        14. lastnamephonetic
        15. middlename
        16. alternatename
        17. username
      4. Set issuer's requireconfirmation value to 0 (I could change this value only from DB)
      5. Log in with OAuth2
      6. Go to Profile / Edit Profile
      7. On the Edit profile page you should see all the mapped and sent values. 
      Show
      case 1 - E-mail confirmation required:   Enable OAuth2 authentication plugin (Site administration > plugins > manage authentication) Set up an OAuth2 issuer Setting up OAuth2 can be tricky, it is recommended to review the documentation here: https://docs.moodle.org/311/en/OAuth_2_services) Setup a Microsoft provider, using the guide here: https://docs.moodle.org/311/en/OAuth_2_Microsoft_service (It doesn't have to be MS, but it is one of the easier ones to setup, and it allows "localhost") Set up field mappings for the following fields:  Note: Depending on what data you set on the provider side there might not be enough fields "sent" to Moodle to map to all available user profile fields. Another option is to start with the default fields and then after testing map the data from the provider to other Moodle user profile fields. For example take the country field from the provider and map it to the "idnumber" field in Moodle firstname lastname city country lang description url idnumber institution department phone1 phone2 firstnamephonetic lastnamephonetic middlename alternatename username Log in with OAuth2 Confirm the user Either log into the Moodle instance as a site administrator and confirm the user from the user overview page (Site administration > Users > Browse list of users) OR If the test site can send emails then the test user will receive a confirmation email when they first log in. In this case click the link in the email. Log in with OAuth2  Go to Profile / Edit Profile On the Edit profile page you should see all the mapped and sent values.  case 2 E-mail confirmation is not required:   Enable OAuth2 authentication plugin (Site administration > plugins > manage authentication) Set up an OAuth2 issuer Set up field mappings for the following fields:  firstname lastname city country lang description url idnumber institution department phone1 phone2 firstnamephonetic lastnamephonetic middlename alternatename username Set issuer's requireconfirmation value to 0 (I could change this value only from DB) Log in with OAuth2 Go to Profile / Edit Profile On the Edit profile page you should see all the mapped and sent values. 

    Description

      I have a value I'm that I set up a custom user mapped setting for in OAuth2 to map to the internal field idnumber.

      Looking at the code \moodle\auth\oauth2\classes\api.php, send_confirm_account_email(), not all of the possible internal fields are being mapped to the user object.  I would expect the following to be included in the list of values:

      $user->idnumber = $userinfo['idnumber'];

       

      Attachments

        Issue Links

          Activity

            People

              mattp@catalyst-au.net Matt Porritt
              invisibleotis Eric Bram
              Guillermo Gomez Arias Guillermo Gomez Arias
              Shamim Rezaie Shamim Rezaie
              Carlos Escobedo Carlos Escobedo
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              5 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                17/Jan/22

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours, 35 minutes
                  4h 35m