From 63e47405b262023e00f38a52446609dafbe83ce2 Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Fri, 11 Jul 2014 20:57:00 -0400 Subject: [PATCH] Only update access usernames where the username is changing #282 --- models/user.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/models/user.go b/models/user.go index 47f1d45f0e..7838d2471d 100644 --- a/models/user.go +++ b/models/user.go @@ -297,10 +297,12 @@ func ChangeUserName(user *User, newUserName string) (err error) { } for j := range accesses { - accesses[j].UserName = newUserName - accesses[j].RepoName = newUserName + "/" + repos[i].LowerName - if err = UpdateAccessWithSession(sess, &accesses[j]); err != nil { - return err + // if the access is not the user's access (already updated above) + if accesses[j].UserName != user.LowerName { + accesses[j].RepoName = newUserName + "/" + repos[i].LowerName + if err = UpdateAccessWithSession(sess, &accesses[j]); err != nil { + return err + } } } }