From 63e21c146aa3fda2715d55235d54dfb95a9077cc Mon Sep 17 00:00:00 2001
From: Zachery Hostens <zacheryph@gmail.com>
Date: Mon, 14 Mar 2016 09:40:16 -0500
Subject: [PATCH] =?UTF-8?q?ensure=20we=20don=E2=80=99t=20try=20changing=20?=
 =?UTF-8?q?LDAP=20passswords?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 conf/locale/locale_en-US.ini | 1 +
 routers/user/auth.go         | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini
index 95576ad2c2..a803b68839 100644
--- a/conf/locale/locale_en-US.ini
+++ b/conf/locale/locale_en-US.ini
@@ -162,6 +162,7 @@ reset_password = Reset Your Password
 invalid_code = Sorry, your confirmation code has expired or not valid.
 reset_password_helper = Click here to reset your password
 password_too_short = Password length cannot be less then 6.
+non_local_account = Non-local accounts cannot change passwords through Gogs.
 
 [mail]
 activate_account = Please activate your account
diff --git a/routers/user/auth.go b/routers/user/auth.go
index 3f37b09059..f42ad4f383 100644
--- a/routers/user/auth.go
+++ b/routers/user/auth.go
@@ -297,6 +297,12 @@ func ForgotPasswdPost(ctx *middleware.Context) {
 		return
 	}
 
+	if !u.IsLocal() {
+		ctx.Data["Err_Email"] = true
+		ctx.RenderWithErr(ctx.Tr("auth.non_local_account"), FORGOT_PASSWORD, nil)
+		return
+	}
+
 	if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) {
 		ctx.Data["ResendLimited"] = true
 		ctx.HTML(200, FORGOT_PASSWORD)