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

Impossible to edit profile when the user current email is not allowed by domain restriction

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 4.5.1
    • User management
    • None
    • MOODLE_405_STABLE

      When a user has already registered with a domain and then we restrict the new user to this domain. Exisitng user cannot modify his profile becaus he has a forbidden address. 

       

      Here are the reproduction steps : 

      • Register a new user with example.com
      • Set  the denied domain to example.com
      • Set the Restrict domains when changing email to yes
      • log as the user created in first step
      • Edit your profile and try to change any field. You then have the error message that your email is forbidden. 

      This happens also when you use sso to log user from a domain and restrict thois domain at signup. The sso users can login but they can't edit their profile anymore.

       

      The patch is pretty simple : 

      // 
      diff --git a/user/edit_form.php b/user/edit_form.php
      index 595c733389e..08adf790658 100644
      --- a/user/edit_form.php
      +++ b/user/edit_form.php
      @@ -228,7 +228,7 @@ class user_edit_form extends moodleform {
                   $errors['email'] = get_string('toomanybounces');
               }
       
      -        if (isset($usernew->email) and !empty($CFG->verifychangedemail) and !isset($errors['email']) and !has_capability('moodle/user:update', context_system::instance())) {
      +        if (isset($usernew->email) and $usernew->email != $user->email and !empty($CFG->verifychangedemail) and !isset($errors['email']) and !has_capability('moodle/user:update', context_system::instance())) {
                   $errorstr = email_is_not_allowed($usernew->email);
                   if ($errorstr !== false) {
                       $errors['email'] = $errorstr; 

       

      This activates the email validity check only if user want to change their email.

       

            Unassigned Unassigned
            ndieschburg Noel Dieschburg
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.