From 8b3dc20253c6e2be86089036b36484a9ec747c3b Mon Sep 17 00:00:00 2001
From: skodak <skodak>
Date: Sat, 15 Dec 2007 16:57:20 +0000
Subject: [PATCH] MDL-12580 fixed infinite redirect loop when editing profile
 for the first time; merged from MOODLE_19_STABLE

---
 user/edit.php | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/user/edit.php b/user/edit.php
index 094525328d..db8a645f42 100644
--- a/user/edit.php
+++ b/user/edit.php
@@ -55,8 +55,10 @@
 
     // check access control
     if ($user->id == $USER->id) {
-        //editing own profile
-        require_capability('moodle/user:editownprofile', $systemcontext);
+        //editing own profile - require_login() MUST NOT be used here, it would result in infinite loop!
+        if (!has_capability('moodle/user:editownprofile', $systemcontext)) {
+            error('Can not edit own profile, sorry.');
+        }
 
     } else {
         // teachers, parents, etc.
-- 
2.39.5