* Forgot password should use ResetPwdCodeLives, not ActiveCodeLives * Improve documentation for different send mail functions related to password reset * Improve documentation in conf/app.ini regarding xxx_CODE_LIVE_MINUTES settingstags/v1.2.0-rc1
BLACKLISTED_URIS = | BLACKLISTED_URIS = | ||||
[service] | [service] | ||||
; Time limit to confirm account/email registration (in multiples of 60 minutes) | |||||
ACTIVE_CODE_LIVE_MINUTES = 180 | ACTIVE_CODE_LIVE_MINUTES = 180 | ||||
; Time limit to confirm forgot password reset process (in multiples of 60 minutes) | |||||
RESET_PASSWD_CODE_LIVE_MINUTES = 180 | RESET_PASSWD_CODE_LIVE_MINUTES = 180 | ||||
; User need to confirm e-mail for registration | ; User need to confirm e-mail for registration | ||||
REGISTER_EMAIL_CONFIRM = false | REGISTER_EMAIL_CONFIRM = false |
mailer.SendAsync(msg) | mailer.SendAsync(msg) | ||||
} | } | ||||
// SendActivateAccountMail sends an activation mail to the user | |||||
// SendActivateAccountMail sends an activation mail to the user (new user registration) | |||||
func SendActivateAccountMail(c *macaron.Context, u *User) { | func SendActivateAccountMail(c *macaron.Context, u *User) { | ||||
SendUserMail(c, u, mailAuthActivate, u.GenerateActivateCode(), c.Tr("mail.activate_account"), "activate account") | SendUserMail(c, u, mailAuthActivate, u.GenerateActivateCode(), c.Tr("mail.activate_account"), "activate account") | ||||
} | } | ||||
SendUserMail(c, u, mailAuthResetPassword, u.GenerateActivateCode(), c.Tr("mail.reset_password"), "reset password") | SendUserMail(c, u, mailAuthResetPassword, u.GenerateActivateCode(), c.Tr("mail.reset_password"), "reset password") | ||||
} | } | ||||
// SendActivateEmailMail sends confirmation email. | |||||
// SendActivateEmailMail sends confirmation email to confirm new email address | |||||
func SendActivateEmailMail(c *macaron.Context, u *User, email *EmailAddress) { | func SendActivateEmailMail(c *macaron.Context, u *User, email *EmailAddress) { | ||||
data := map[string]interface{}{ | data := map[string]interface{}{ | ||||
"Username": u.DisplayName(), | "Username": u.DisplayName(), |
forgot_password = Forgot password? | forgot_password = Forgot password? | ||||
sign_up_now = Need an account? Sign up now. | sign_up_now = Need an account? Sign up now. | ||||
confirmation_mail_sent_prompt = A new confirmation email has been sent to <b>%s</b>. Please check your inbox within the next %d hours to complete the registration process. | confirmation_mail_sent_prompt = A new confirmation email has been sent to <b>%s</b>. Please check your inbox within the next %d hours to complete the registration process. | ||||
reset_password_mail_sent_prompt = A confirmation email has been sent to <b>%s</b>. Please check your inbox within the next %d hours to complete the password reset process. | |||||
active_your_account = Activate Your Account | active_your_account = Activate Your Account | ||||
prohibit_login = Login Prohibited | prohibit_login = Login Prohibited | ||||
prohibit_login_desc = Your account is prohibited to login, please contact the site administrator. | prohibit_login_desc = Your account is prohibited to login, please contact the site administrator. |
u, err := models.GetUserByEmail(email) | u, err := models.GetUserByEmail(email) | ||||
if err != nil { | if err != nil { | ||||
if models.IsErrUserNotExist(err) { | if models.IsErrUserNotExist(err) { | ||||
ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60 | |||||
ctx.Data["Hours"] = setting.Service.ResetPwdCodeLives / 60 | |||||
ctx.Data["IsResetSent"] = true | ctx.Data["IsResetSent"] = true | ||||
ctx.HTML(200, tplForgotPassword) | ctx.HTML(200, tplForgotPassword) | ||||
return | return | ||||
log.Error(4, "Set cache(MailResendLimit) fail: %v", err) | log.Error(4, "Set cache(MailResendLimit) fail: %v", err) | ||||
} | } | ||||
ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60 | |||||
ctx.Data["Hours"] = setting.Service.ResetPwdCodeLives / 60 | |||||
ctx.Data["IsResetSent"] = true | ctx.Data["IsResetSent"] = true | ||||
ctx.HTML(200, tplForgotPassword) | ctx.HTML(200, tplForgotPassword) | ||||
} | } |
<div class="ui attached segment"> | <div class="ui attached segment"> | ||||
{{template "base/alert" .}} | {{template "base/alert" .}} | ||||
{{if .IsResetSent}} | {{if .IsResetSent}} | ||||
<p>{{.i18n.Tr "auth.confirmation_mail_sent_prompt" .Email .Hours | Str2html}}</p> | |||||
<p>{{.i18n.Tr "auth.reset_password_mail_sent_prompt" .Email .Hours | Str2html}}</p> | |||||
{{else if .IsResetRequest}} | {{else if .IsResetRequest}} | ||||
<div class="required inline field {{if .Err_Email}}error{{end}}"> | <div class="required inline field {{if .Err_Email}}error{{end}}"> | ||||
<label for="email">{{.i18n.Tr "email"}}</label> | <label for="email">{{.i18n.Tr "email"}}</label> |