| @@ -1625,6 +1625,26 @@ func GetUserByEmail(email string) (*User, error) { | |||||
| return GetUserByEmailContext(DefaultDBContext(), email) | return GetUserByEmailContext(DefaultDBContext(), email) | ||||
| } | } | ||||
| func GetUserByMainEmail(email string) (*User, error) { | |||||
| if len(email) == 0 { | |||||
| return nil, ErrUserNotExist{0, email, 0} | |||||
| } | |||||
| email = strings.ToLower(email) | |||||
| // First try to find the user by primary email | |||||
| user := &User{Email: email} | |||||
| has, err := DefaultDBContext().e.Get(user) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if has { | |||||
| return user, nil | |||||
| } else { | |||||
| return nil, ErrUserNotExist{0, email, 0} | |||||
| } | |||||
| } | |||||
| // GetUserByEmailContext returns the user object by given e-mail if exists with db context | // GetUserByEmailContext returns the user object by given e-mail if exists with db context | ||||
| func GetUserByEmailContext(ctx DBContext, email string) (*User, error) { | func GetUserByEmailContext(ctx DBContext, email string) (*User, error) { | ||||
| if len(email) == 0 { | if len(email) == 0 { | ||||
| @@ -335,6 +335,8 @@ resent_limit_prompt = You have already requested an activation email recently. P | |||||
| has_unconfirmed_mail = Hi %s, you have an unconfirmed email address (<b>%s</b>). If you haven't received a confirmation email or need to resend a new one, please click on the button below. | has_unconfirmed_mail = Hi %s, you have an unconfirmed email address (<b>%s</b>). If you haven't received a confirmation email or need to resend a new one, please click on the button below. | ||||
| resend_mail = Click here to resend your activation email | resend_mail = Click here to resend your activation email | ||||
| email_not_associate = The email address is not associated with any account. | email_not_associate = The email address is not associated with any account. | ||||
| email_not_main=The email address is wrong, please input your primary email address. | |||||
| email_not_right=The email address is not associated with any account, please input the right email address. | |||||
| send_reset_mail = Send Account Recovery Email | send_reset_mail = Send Account Recovery Email | ||||
| reset_password = Account Recovery | reset_password = Account Recovery | ||||
| invalid_code = Your confirmation code is invalid or has expired. | invalid_code = Your confirmation code is invalid or has expired. | ||||
| @@ -339,6 +339,8 @@ resent_limit_prompt=您请求发送激活邮件过于频繁,请等待 3 分钟 | |||||
| has_unconfirmed_mail=%s 您好,系统检测到您有一封发送至 <b>%s</b> 但未被确认的邮件。如果您未收到激活邮件,或需要重新发送,请单击下方的按钮。 | has_unconfirmed_mail=%s 您好,系统检测到您有一封发送至 <b>%s</b> 但未被确认的邮件。如果您未收到激活邮件,或需要重新发送,请单击下方的按钮。 | ||||
| resend_mail=单击此处重新发送确认邮件 | resend_mail=单击此处重新发送确认邮件 | ||||
| email_not_associate=您输入的邮箱地址未被关联到任何帐号! | email_not_associate=您输入的邮箱地址未被关联到任何帐号! | ||||
| email_not_main=电子邮箱地址不正确,请输入您设置的主要邮箱地址。 | |||||
| email_not_right=您输入了不存在的邮箱地址,请输入正确的邮箱地址。 | |||||
| send_reset_mail=发送账户恢复邮件 | send_reset_mail=发送账户恢复邮件 | ||||
| reset_password=账户恢复 | reset_password=账户恢复 | ||||
| invalid_code=此确认密钥无效或已过期。 | invalid_code=此确认密钥无效或已过期。 | ||||
| @@ -1425,12 +1425,16 @@ func ForgotPasswdPost(ctx *context.Context) { | |||||
| email := ctx.Query("email") | email := ctx.Query("email") | ||||
| ctx.Data["Email"] = email | ctx.Data["Email"] = email | ||||
| u, err := models.GetUserByEmail(email) | |||||
| u, err := models.GetUserByMainEmail(email) | |||||
| if err != nil { | if err != nil { | ||||
| if models.IsErrUserNotExist(err) { | if models.IsErrUserNotExist(err) { | ||||
| ctx.Data["ResetPwdCodeLives"] = timeutil.MinutesToFriendly(setting.Service.ResetPwdCodeLives, ctx.Locale.Language()) | ctx.Data["ResetPwdCodeLives"] = timeutil.MinutesToFriendly(setting.Service.ResetPwdCodeLives, ctx.Locale.Language()) | ||||
| ctx.Data["IsResetSent"] = true | |||||
| ctx.HTML(200, tplForgotPassword) | |||||
| ctx.Data["IsResetSent"] = false | |||||
| if used, _ := models.IsEmailUsed(email); used { | |||||
| ctx.RenderWithErr(ctx.Tr("auth.email_not_main"), tplForgotPassword, nil) | |||||
| } else { | |||||
| ctx.RenderWithErr(ctx.Tr("auth.email_not_right"), tplForgotPassword, nil) | |||||
| } | |||||
| return | return | ||||
| } | } | ||||