oauth does not update user profile fields

oauth does not update user profile fields

by Robert Schrenk -
Number of replies: 1
Picture of Core developers Picture of Plugin developers

Hello,

On our site users are log in via oAuth using Microsoft. When we update user profile data in Azure they will not be updated on our Moodle site.

I debugged the login procedure and found out that the profile fields are successfully retrieved in the "complete_login"-function. The variable $userinfo contains everything correctly. Nevertheless nothing gets updated.

I saw in the code that based on the data from $userinfo a mapped user is retrieved. If the script finds a user it seems to overwrite $userinfo.

} else if ($mappeduser && $mappeduser->confirmed) {
     $userinfo = (array) $mappeduser;
     $userwasmapped = true;
}

Does anybody has a solution for this?

Kind regards



Average of ratings: -
In reply to Robert Schrenk

Re: oauth does not update user profile fields

by Daniel Dubbeldam -
I think I have the same problem. 
let me clarify, so you can decide it is the same problem:

I have a working OAUTH2 connection with an Azure environment.  This connection as such works fine.

there are, however, 2 issues i'm encountering:

  1. if a user already exists in Moodle it does not get updated through Azure. In Example:
    - I created a manual account in Moodle with name "firstname lastname" and the right e-mailadress.
    - User with that e-mailadress logs in through the Oauth connection.
    - user sees "firstname lastname" in Moodle instead of his real name.
    * this however might be solved through https://tracker.moodle.org/browse/MDL-61767
  2. The user from 1 is in a certain "Department" in Azure. under "admin/tool/oauth2/userfieldmappings.php?issuerid=1" I have mapped this field with the moodle field "Institution":
    user field mapping
    However... This field is not set when a user is created nor updated when the users is already known in Moodle and (re-)logs in..

This second issue is bugging me. some who can help me? If this is NOT related to the question of Robert Schrenk, please feel free to create a fork of this issue ;) 

Daniel Dubbeldam