- #1496: fallback plain text - #1002: add date header - #913: fix encoding of headertags/v1.21.12.1
@@ -33,6 +33,7 @@ github.com/russross/blackfriday = commit:8cec3a854e | |||
github.com/shurcooL/sanitized_anchor_name = commit:244f5ac324 | |||
golang.org/x/net = | |||
golang.org/x/text = | |||
gopkg.in/gomail.v2 = | |||
gopkg.in/ini.v1 = commit:463307112d | |||
gopkg.in/redis.v2 = commit:e617904962 | |||
@@ -160,6 +160,11 @@ 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. | |||
[mail] | |||
register_success = Register success, Welcome | |||
activate_account = Please activate your account | |||
activate_email = Verify your e-mail address | |||
[modal] | |||
yes = Yes | |||
no = No | |||
@@ -133,6 +133,22 @@ func (u *User) HomeLink() string { | |||
return setting.AppSubUrl + "/" + u.Name | |||
} | |||
// GenerateEmailActivateCode generates an activate code based on user information and given e-mail. | |||
func (u *User) GenerateEmailActivateCode(email string) string { | |||
code := base.CreateTimeLimitCode( | |||
com.ToStr(u.Id)+email+u.LowerName+u.Passwd+u.Rands, | |||
setting.Service.ActiveCodeLives, nil) | |||
// Add tail hex username | |||
code += hex.EncodeToString([]byte(u.LowerName)) | |||
return code | |||
} | |||
// GenerateActivateCode generates an activate code based on user information. | |||
func (u *User) GenerateActivateCode() string { | |||
return u.GenerateEmailActivateCode(u.Email) | |||
} | |||
// CustomAvatarPath returns user custom avatar file path. | |||
func (u *User) CustomAvatarPath() string { | |||
return filepath.Join(setting.AvatarUploadPath, com.ToStr(u.Id)) | |||
@@ -5,12 +5,10 @@ | |||
package mailer | |||
import ( | |||
"encoding/hex" | |||
"errors" | |||
"fmt" | |||
"path" | |||
"github.com/Unknwon/com" | |||
"github.com/Unknwon/macaron" | |||
"github.com/gogits/gogs/models" | |||
@@ -20,26 +18,16 @@ import ( | |||
) | |||
const ( | |||
AUTH_ACTIVE base.TplName = "mail/auth/active" | |||
AUTH_ACTIVATE_EMAIL base.TplName = "mail/auth/activate_email" | |||
AUTH_REGISTER_SUCCESS base.TplName = "mail/auth/register_success" | |||
AUTH_ACTIVATE base.TplName = "mail/auth/activate" | |||
AUTH_ACTIVATE_EMAIL base.TplName = "mail/auth/activate_email" | |||
AUTH_RESET_PASSWORD base.TplName = "mail/auth/reset_passwd" | |||
NOTIFY_COLLABORATOR base.TplName = "mail/notify/collaborator" | |||
NOTIFY_MENTION base.TplName = "mail/notify/mention" | |||
) | |||
// Create New mail message use MailFrom and MailUser | |||
func NewMailMessageFrom(To []string, from, subject, body string) Message { | |||
return NewHtmlMessage(To, from, subject, body) | |||
} | |||
// Create New mail message use MailFrom and MailUser | |||
func NewMailMessage(To []string, subject, body string) Message { | |||
return NewMailMessageFrom(To, setting.MailService.From, subject, body) | |||
} | |||
func GetMailTmplData(u *models.User) map[interface{}]interface{} { | |||
func ComposeTplData(u *models.User) map[interface{}]interface{} { | |||
data := make(map[interface{}]interface{}, 10) | |||
data["AppName"] = setting.AppName | |||
data["AppVer"] = setting.AppVer | |||
@@ -52,95 +40,45 @@ func GetMailTmplData(u *models.User) map[interface{}]interface{} { | |||
return data | |||
} | |||
// create a time limit code for user active | |||
func CreateUserActiveCode(u *models.User, startInf interface{}) string { | |||
minutes := setting.Service.ActiveCodeLives | |||
data := com.ToStr(u.Id) + u.Email + u.LowerName + u.Passwd + u.Rands | |||
code := base.CreateTimeLimitCode(data, minutes, startInf) | |||
// add tail hex username | |||
code += hex.EncodeToString([]byte(u.LowerName)) | |||
return code | |||
} | |||
// create a time limit code for user active | |||
func CreateUserEmailActivateCode(u *models.User, e *models.EmailAddress, startInf interface{}) string { | |||
minutes := setting.Service.ActiveCodeLives | |||
data := com.ToStr(u.Id) + e.Email + u.LowerName + u.Passwd + u.Rands | |||
code := base.CreateTimeLimitCode(data, minutes, startInf) | |||
// add tail hex username | |||
code += hex.EncodeToString([]byte(u.LowerName)) | |||
return code | |||
} | |||
// Send user register mail with active code | |||
func SendRegisterMail(r macaron.Render, u *models.User) { | |||
code := CreateUserActiveCode(u, nil) | |||
subject := "Register success, Welcome" | |||
data := GetMailTmplData(u) | |||
data["Code"] = code | |||
body, err := r.HTMLString(string(AUTH_REGISTER_SUCCESS), data) | |||
if err != nil { | |||
log.Error(4, "mail.SendRegisterMail(fail to render): %v", err) | |||
return | |||
} | |||
msg := NewMailMessage([]string{u.Email}, subject, body) | |||
msg.Info = fmt.Sprintf("UID: %d, send register mail", u.Id) | |||
SendAsync(&msg) | |||
} | |||
// Send email verify active email. | |||
func SendActiveMail(r macaron.Render, u *models.User) { | |||
code := CreateUserActiveCode(u, nil) | |||
subject := "Verify your e-mail address" | |||
data := GetMailTmplData(u) | |||
data["Code"] = code | |||
body, err := r.HTMLString(string(AUTH_ACTIVE), data) | |||
func SendActivateAccountMail(c *macaron.Context, u *models.User) { | |||
data := ComposeTplData(u) | |||
data["Code"] = u.GenerateActivateCode() | |||
body, err := c.HTMLString(string(AUTH_ACTIVATE), data) | |||
if err != nil { | |||
log.Error(4, "mail.SendActiveMail(fail to render): %v", err) | |||
log.Error(4, "HTMLString: %v", err) | |||
return | |||
} | |||
msg := NewMailMessage([]string{u.Email}, subject, body) | |||
msg.Info = fmt.Sprintf("UID: %d, send active mail", u.Id) | |||
msg := NewMessage([]string{u.Email}, c.Tr("mail.activate_account"), body) | |||
msg.Info = fmt.Sprintf("UID: %d, activate account", u.Id) | |||
SendAsync(&msg) | |||
SendAsync(msg) | |||
} | |||
// Send email to verify secondary email. | |||
func SendActivateEmail(r macaron.Render, user *models.User, email *models.EmailAddress) { | |||
code := CreateUserEmailActivateCode(user, email, nil) | |||
subject := "Verify your e-mail address" | |||
data := GetMailTmplData(user) | |||
data["Code"] = code | |||
// SendActivateAccountMail sends confirmation e-mail. | |||
func SendActivateEmailMail(c *macaron.Context, u *models.User, email *models.EmailAddress) { | |||
data := ComposeTplData(u) | |||
data["Code"] = u.GenerateEmailActivateCode(email.Email) | |||
data["Email"] = email.Email | |||
body, err := r.HTMLString(string(AUTH_ACTIVATE_EMAIL), data) | |||
body, err := c.HTMLString(string(AUTH_ACTIVATE_EMAIL), data) | |||
if err != nil { | |||
log.Error(4, "mail.SendActiveMail(fail to render): %v", err) | |||
log.Error(4, "HTMLString: %v", err) | |||
return | |||
} | |||
msg := NewMailMessage([]string{email.Email}, subject, body) | |||
msg.Info = fmt.Sprintf("UID: %d, send activate email to %s", user.Id, email.Email) | |||
msg := NewMessage([]string{email.Email}, c.Tr("mail.activate_email"), body) | |||
msg.Info = fmt.Sprintf("UID: %d, activate email: %s", u.Id, email.Email) | |||
SendAsync(&msg) | |||
SendAsync(msg) | |||
} | |||
// Send reset password email. | |||
func SendResetPasswdMail(r macaron.Render, u *models.User) { | |||
code := CreateUserActiveCode(u, nil) | |||
code := u.GenerateActivateCode() | |||
subject := "Reset your password" | |||
data := GetMailTmplData(u) | |||
data := ComposeTplData(u) | |||
data["Code"] = code | |||
body, err := r.HTMLString(string(AUTH_RESET_PASSWORD), data) | |||
if err != nil { | |||
@@ -148,10 +86,10 @@ func SendResetPasswdMail(r macaron.Render, u *models.User) { | |||
return | |||
} | |||
msg := NewMailMessage([]string{u.Email}, subject, body) | |||
msg := NewMessage([]string{u.Email}, subject, body) | |||
msg.Info = fmt.Sprintf("UID: %d, send reset password email", u.Id) | |||
SendAsync(&msg) | |||
SendAsync(msg) | |||
} | |||
// SendIssueNotifyMail sends mail notification of all watchers of repository. | |||
@@ -182,9 +120,9 @@ func SendIssueNotifyMail(u, owner *models.User, repo *models.Repository, issue * | |||
content := fmt.Sprintf("%s<br>-<br> <a href=\"%s%s/%s/issues/%d\">View it on Gogs</a>.", | |||
base.RenderSpecialLink([]byte(issue.Content), owner.Name+"/"+repo.Name), | |||
setting.AppUrl, owner.Name, repo.Name, issue.Index) | |||
msg := NewMailMessageFrom(tos, u.Email, subject, content) | |||
msg := NewMessageFrom(tos, u.Email, subject, content) | |||
msg.Info = fmt.Sprintf("Subject: %s, send issue notify emails", subject) | |||
SendAsync(&msg) | |||
SendAsync(msg) | |||
return tos, nil | |||
} | |||
@@ -198,7 +136,7 @@ func SendIssueMentionMail(r macaron.Render, u, owner *models.User, | |||
subject := fmt.Sprintf("[%s] %s (#%d)", repo.Name, issue.Name, issue.Index) | |||
data := GetMailTmplData(nil) | |||
data := ComposeTplData(nil) | |||
data["IssueLink"] = fmt.Sprintf("%s/%s/issues/%d", owner.Name, repo.Name, issue.Index) | |||
data["Subject"] = subject | |||
@@ -207,9 +145,9 @@ func SendIssueMentionMail(r macaron.Render, u, owner *models.User, | |||
return fmt.Errorf("mail.SendIssueMentionMail(fail to render): %v", err) | |||
} | |||
msg := NewMailMessageFrom(tos, u.Email, subject, body) | |||
msg := NewMessageFrom(tos, u.Email, subject, body) | |||
msg.Info = fmt.Sprintf("Subject: %s, send issue mention emails", subject) | |||
SendAsync(&msg) | |||
SendAsync(msg) | |||
return nil | |||
} | |||
@@ -219,7 +157,7 @@ func SendCollaboratorMail(r macaron.Render, u, owner *models.User, | |||
subject := fmt.Sprintf("%s added you to %s", owner.Name, repo.Name) | |||
data := GetMailTmplData(nil) | |||
data := ComposeTplData(nil) | |||
data["RepoLink"] = path.Join(owner.Name, repo.Name) | |||
data["Subject"] = subject | |||
@@ -228,9 +166,9 @@ func SendCollaboratorMail(r macaron.Render, u, owner *models.User, | |||
return fmt.Errorf("mail.SendCollaboratorMail(fail to render): %v", err) | |||
} | |||
msg := NewMailMessage([]string{u.Email}, subject, body) | |||
msg := NewMessage([]string{u.Email}, subject, body) | |||
msg.Info = fmt.Sprintf("UID: %d, send register mail", u.Id) | |||
SendAsync(&msg) | |||
SendAsync(msg) | |||
return nil | |||
} |
@@ -7,16 +7,44 @@ package mailer | |||
import ( | |||
"crypto/tls" | |||
"fmt" | |||
"io" | |||
"net" | |||
"net/mail" | |||
"net/smtp" | |||
"os" | |||
"strings" | |||
"time" | |||
"gopkg.in/gomail.v2" | |||
"github.com/gogits/gogs/modules/log" | |||
"github.com/gogits/gogs/modules/setting" | |||
) | |||
type Message struct { | |||
Info string // Message information for log purpose. | |||
*gomail.Message | |||
} | |||
// NewMessageFrom creates new mail message object with custom From header. | |||
func NewMessageFrom(to []string, from, subject, body string) *Message { | |||
msg := gomail.NewMessage() | |||
msg.SetHeader("From", from) | |||
msg.SetHeader("To", to...) | |||
msg.SetHeader("Subject", subject) | |||
msg.SetDateHeader("Date", time.Now()) | |||
msg.SetBody("text/plain", body) | |||
msg.AddAlternative("text/html", body) | |||
return &Message{ | |||
Message: msg, | |||
} | |||
} | |||
// NewMessage creates new mail message object with default From header. | |||
func NewMessage(to []string, subject, body string) *Message { | |||
return NewMessageFrom(to, setting.MailService.From, subject, body) | |||
} | |||
type loginAuth struct { | |||
username, password string | |||
} | |||
@@ -44,74 +72,24 @@ func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) { | |||
return nil, nil | |||
} | |||
type Message struct { | |||
To []string | |||
From string | |||
Subject string | |||
ReplyTo string | |||
Body string | |||
Type string | |||
Massive bool | |||
Info string | |||
} | |||
// create mail content | |||
func (m Message) Content() string { | |||
// set mail type | |||
contentType := "text/plain; charset=UTF-8" | |||
if m.Type == "html" { | |||
contentType = "text/html; charset=UTF-8" | |||
} | |||
// create mail content | |||
content := "From: " + m.From + "\r\nReply-To: " + m.ReplyTo + "\r\nSubject: " + m.Subject + "\r\nContent-Type: " + contentType + "\r\n\r\n" + m.Body | |||
return content | |||
type Sender struct { | |||
} | |||
var mailQueue chan *Message | |||
func NewContext() { | |||
if setting.MailService == nil { | |||
return | |||
} | |||
mailQueue = make(chan *Message, setting.MailService.QueueLength) | |||
go processMailQueue() | |||
} | |||
func processMailQueue() { | |||
for { | |||
select { | |||
case msg := <-mailQueue: | |||
num, err := Send(msg) | |||
tos := strings.Join(msg.To, ", ") | |||
info := "" | |||
if err != nil { | |||
if len(msg.Info) > 0 { | |||
info = ", info: " + msg.Info | |||
} | |||
log.Error(4, fmt.Sprintf("Async sent email %d succeed, not send emails: %s%s err: %s", num, tos, info, err)) | |||
} else { | |||
log.Trace(fmt.Sprintf("Async sent email %d succeed, sent emails: %s%s", num, tos, info)) | |||
} | |||
} | |||
} | |||
} | |||
func (s *Sender) Send(from string, to []string, msg io.WriterTo) error { | |||
opts := setting.MailService | |||
// sendMail allows mail with self-signed certificates. | |||
func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte) error { | |||
host, port, err := net.SplitHostPort(settings.Host) | |||
host, port, err := net.SplitHostPort(opts.Host) | |||
if err != nil { | |||
return err | |||
} | |||
tlsconfig := &tls.Config{ | |||
InsecureSkipVerify: settings.SkipVerify, | |||
InsecureSkipVerify: opts.SkipVerify, | |||
ServerName: host, | |||
} | |||
if settings.UseCertificate { | |||
cert, err := tls.LoadX509KeyPair(settings.CertFile, settings.KeyFile) | |||
if opts.UseCertificate { | |||
cert, err := tls.LoadX509KeyPair(opts.CertFile, opts.KeyFile) | |||
if err != nil { | |||
return err | |||
} | |||
@@ -159,17 +137,16 @@ func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte) | |||
} | |||
canAuth, options := client.Extension("AUTH") | |||
if canAuth && len(settings.User) > 0 { | |||
if canAuth && len(opts.User) > 0 { | |||
var auth smtp.Auth | |||
if strings.Contains(options, "CRAM-MD5") { | |||
auth = smtp.CRAMMD5Auth(settings.User, settings.Passwd) | |||
auth = smtp.CRAMMD5Auth(opts.User, opts.Passwd) | |||
} else if strings.Contains(options, "PLAIN") { | |||
auth = smtp.PlainAuth("", settings.User, settings.Passwd, host) | |||
auth = smtp.PlainAuth("", opts.User, opts.Passwd, host) | |||
} else if strings.Contains(options, "LOGIN") { | |||
// Patch for AUTH LOGIN | |||
auth = LoginAuth(settings.User, settings.Passwd) | |||
auth = LoginAuth(opts.User, opts.Passwd) | |||
} | |||
if auth != nil { | |||
@@ -179,15 +156,11 @@ func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte) | |||
} | |||
} | |||
if fromAddress, err := mail.ParseAddress(settings.From); err != nil { | |||
if err = client.Mail(from); err != nil { | |||
return err | |||
} else { | |||
if err = client.Mail(fromAddress.Address); err != nil { | |||
return err | |||
} | |||
} | |||
for _, rec := range recipients { | |||
for _, rec := range to { | |||
if err = client.Rcpt(rec); err != nil { | |||
return err | |||
} | |||
@@ -196,71 +169,44 @@ func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte) | |||
w, err := client.Data() | |||
if err != nil { | |||
return err | |||
} | |||
if _, err = w.Write([]byte(msgContent)); err != nil { | |||
} else if _, err = msg.WriteTo(w); err != nil { | |||
return err | |||
} | |||
if err = w.Close(); err != nil { | |||
} else if err = w.Close(); err != nil { | |||
return err | |||
} | |||
return client.Quit() | |||
} | |||
// Direct Send mail message | |||
func Send(msg *Message) (int, error) { | |||
log.Trace("Sending mails to: %s", strings.Join(msg.To, ", ")) | |||
// get message body | |||
content := msg.Content() | |||
if len(msg.To) == 0 { | |||
return 0, fmt.Errorf("empty receive emails") | |||
} else if len(msg.Body) == 0 { | |||
return 0, fmt.Errorf("empty email body") | |||
} | |||
func processMailQueue() { | |||
sender := &Sender{} | |||
if msg.Massive { | |||
// send mail to multiple emails one by one | |||
num := 0 | |||
for _, to := range msg.To { | |||
body := []byte("To: " + to + "\r\n" + content) | |||
err := sendMail(setting.MailService, []string{to}, body) | |||
if err != nil { | |||
return num, err | |||
for { | |||
select { | |||
case msg := <-mailQueue: | |||
log.Trace("New e-mail sending request %s: %s", msg.GetHeader("To"), msg.Info) | |||
if err := gomail.Send(sender, msg.Message); err != nil { | |||
log.Error(4, "Fail to send e-mails %s: %s - %v", msg.GetHeader("To"), msg.Info, err) | |||
} else { | |||
log.Trace("E-mails sent %s: %s", msg.GetHeader("To"), msg.Info) | |||
} | |||
num++ | |||
} | |||
return num, nil | |||
} else { | |||
body := []byte("To: " + strings.Join(msg.To, ",") + "\r\n" + content) | |||
} | |||
} | |||
// send to multiple emails in one message | |||
err := sendMail(setting.MailService, msg.To, body) | |||
if err != nil { | |||
return 0, err | |||
} else { | |||
return 1, nil | |||
} | |||
var mailQueue chan *Message | |||
func NewContext() { | |||
if setting.MailService == nil { | |||
return | |||
} | |||
mailQueue = make(chan *Message, setting.MailService.QueueLength) | |||
go processMailQueue() | |||
} | |||
// Async Send mail message | |||
func SendAsync(msg *Message) { | |||
go func() { | |||
mailQueue <- msg | |||
}() | |||
} | |||
// Create html mail message | |||
func NewHtmlMessage(To []string, From, Subject, Body string) Message { | |||
return Message{ | |||
To: To, | |||
From: setting.MailService.From, | |||
ReplyTo: From, | |||
Subject: Subject, | |||
Body: Body, | |||
Type: "html", | |||
} | |||
} |
@@ -46,6 +46,7 @@ | |||
} | |||
} | |||
.user.activate, | |||
.signin, | |||
.signup { | |||
@input-padding: 200px!important; | |||
@@ -20,5 +20,6 @@ func TemplatePreview(ctx *middleware.Context) { | |||
ctx.Data["ActiveCodeLives"] = setting.Service.ActiveCodeLives / 60 | |||
ctx.Data["ResetPwdCodeLives"] = setting.Service.ResetPwdCodeLives / 60 | |||
ctx.Data["CurDbValue"] = "" | |||
ctx.HTML(200, base.TplName(ctx.Params("*"))) | |||
} |
@@ -45,6 +45,7 @@ func checkRunMode() { | |||
func NewServices() { | |||
setting.NewServices() | |||
mailer.NewContext() | |||
social.NewOauthService() | |||
} | |||
@@ -53,7 +54,6 @@ func GlobalInit() { | |||
setting.NewContext() | |||
log.Trace("Custom path: %s", setting.CustomPath) | |||
log.Trace("Log path: %s", setting.LogRootPath) | |||
mailer.NewContext() | |||
models.LoadConfigs() | |||
NewServices() | |||
@@ -249,7 +249,7 @@ func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.Registe | |||
// Send confirmation e-mail, no need for social account. | |||
if !isOauth && setting.Service.RegisterEmailConfirm && u.Id > 1 { | |||
mailer.SendRegisterMail(ctx.Render, u) | |||
mailer.SendActivateAccountMail(ctx.Context, u) | |||
ctx.Data["IsSendRegisterMail"] = true | |||
ctx.Data["Email"] = u.Email | |||
ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60 | |||
@@ -278,7 +278,7 @@ func Activate(ctx *middleware.Context) { | |||
ctx.Data["ResendLimited"] = true | |||
} else { | |||
ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60 | |||
mailer.SendActiveMail(ctx.Render, ctx.User) | |||
mailer.SendActivateAccountMail(ctx.Context, ctx.User) | |||
if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil { | |||
log.Error(4, "Set cache(MailResendLimit) fail: %v", err) | |||
@@ -225,7 +225,7 @@ func SettingsEmailPost(ctx *middleware.Context, form auth.AddEmailForm) { | |||
// Send confirmation e-mail | |||
if setting.Service.RegisterEmailConfirm { | |||
mailer.SendActivateEmail(ctx.Render, ctx.User, e) | |||
mailer.SendActivateEmailMail(ctx.Context, ctx.User, e) | |||
if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil { | |||
log.Error(4, "Set cache(MailResendLimit) fail: %v", err) | |||
@@ -0,0 +1,15 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |||
<title>{{.User.Name}}, please activate your account</title> | |||
</head> | |||
<body> | |||
<p>Hi <b>{{.User.Name}}</b>, thanks for registering at {{.AppName}}!</p> | |||
<p>Please click the following link to verify your e-mail address within <b>{{.ActiveCodeLives}} hours</b>:</p> | |||
<p><a href="{{.AppUrl}}user/activate?code={{.Code}}">{{.AppUrl}}user/activate?code={{.Code}}</a></p> | |||
<p>Not working? Try copying and pasting it to your browser.</p> | |||
<p>© 2015 <a target="_blank" href="http://gogs.io">Gogs: Go Git Service</a></p> | |||
</body> | |||
</html> |
@@ -1,33 +0,0 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |||
<title>{{.User.Name}}, please activate your account</title> | |||
</head> | |||
<body style="background:#eee;"> | |||
<div style="color:#333; font:12px/1.5 Tahoma,Arial,sans-serif;; text-shadow:1px 1px #fff; padding:0; margin:0;"> | |||
<div style="width:600px;margin:0 auto; padding:40px 0 20px;"> | |||
<div style="border:1px solid #d9d9d9;border-radius:3px; background:#fff; box-shadow: 0px 2px 5px rgba(0, 0, 0,.05); -webkit-box-shadow: 0px 2px 5px rgba(0, 0, 0,.05);"> | |||
<div style="padding: 20px 15px;"> | |||
<h1 style="font-size:20px; padding:10px 0 20px; margin:0; border-bottom:1px solid #ddd;"><img src="{{.AppUrl}}/img/favicon.png" style="height: 32px; margin-bottom: -10px;"> <a style="color:#333;text-decoration:none;" target="_blank" href="{{.AppUrl}}">{{.AppName}}</a></h1> | |||
<div style="padding:40px 15px;"> | |||
<div style="font-size:16px; padding-bottom:30px; font-weight:bold;"> | |||
Hi <span style="color: #00BFFF;">{{.User.Name}}</span>, | |||
</div> | |||
<div style="font-size:14px; padding:0 15px;"> | |||
<p style="margin:0;padding:0 0 9px 0;">Please click the following link to verify your e-mail address within <b>{{.ActiveCodeLives}} hours</b>.</p> | |||
<p style="margin:0;padding:0 0 9px 0;"> | |||
<a href="{{.AppUrl}}user/activate?code={{.Code}}">{{.AppUrl}}user/activate?code={{.Code}}</a> | |||
</p> | |||
<p style="margin:0;padding:0 0 9px 0;">Not working? Try copying and pasting it to your browser.</p> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<div style="color:#aaa;padding:10px;text-align:center;"> | |||
© 2014 <a style="color:#888;text-decoration:none;" target="_blank" href="http://gogits.org">Gogs: Go Git Service</a> | |||
</div> | |||
</div> | |||
</div> | |||
</body> | |||
</html> |
@@ -1,33 +1,22 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<html> | |||
<head> | |||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |||
<title>{{.User.Name}}, welcome to {{.AppName}}</title> | |||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |||
<title>{{.User.Name}}, welcome to {{.AppName}}</title> | |||
</head> | |||
<body style="background:#eee;"> | |||
<div style="color:#333; font:12px/1.5 Tahoma,Arial,sans-serif;; text-shadow:1px 1px #fff; padding:0; margin:0;"> | |||
<div style="width:600px;margin:0 auto; padding:40px 0 20px;"> | |||
<div style="border:1px solid #d9d9d9;border-radius:3px; background:#fff; box-shadow: 0px 2px 5px rgba(0, 0, 0,.05); -webkit-box-shadow: 0px 2px 5px rgba(0, 0, 0,.05);"> | |||
<div style="padding: 20px 15px;"> | |||
<h1 style="font-size:20px; padding:10px 0 20px; margin:0; border-bottom:1px solid #ddd;"><img src="{{.AppUrl}}/img/favicon.png" style="height: 32px; margin-bottom: -10px;"> <a style="color:#333;text-decoration:none;" target="_blank" href="{{.AppUrl}}">{{.AppName}}</a></h1> | |||
<div style="padding:40px 15px;"> | |||
<div style="font-size:16px; padding-bottom:30px; font-weight:bold;"> | |||
Hi <span style="color: #00BFFF;">{{.User.Name}}</span>, this is your registration email for {{.AppName}}! | |||
</div> | |||
<div style="font-size:14px; padding:0 15px;"> | |||
<p style="margin:0;padding:0 0 9px 0;">Please click the following link to verify your e-mail address within <b>{{.ActiveCodeLives}} hours</b>.</p> | |||
<p style="margin:0;padding:0 0 9px 0;"> | |||
<a href="{{.AppUrl}}user/activate?code={{.Code}}">{{.AppUrl}}user/activate?code={{.Code}}</a> | |||
</p> | |||
<p style="margin:0;padding:0 0 9px 0;">Not working? Try copying and pasting it to your browser.</p> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<div style="color:#aaa;padding:10px;text-align:center;"> | |||
© 2014 <a style="color:#888;text-decoration:none;" target="_blank" href="http://gogits.org">Gogs: Go Git Service</a> | |||
</div> | |||
<body class="mail register success"> | |||
<div class="ui segment"> | |||
<div class="ui header"> | |||
<img class="ui image" src="{{.AppUrl}}/img/favicon.png"> | |||
{{.AppName}} | |||
</div> | |||
</div> | |||
<div class="ui divider"></div> | |||
<p>Hi <b>{{.User.Name}}</b>, this is your registration email for {{.AppName}}!</p> | |||
<p>Please click the following link to verify your e-mail address within <b>{{.ActiveCodeLives}} hours</b>:</p> | |||
<p><a href="{{.AppUrl}}user/activate?code={{.Code}}">{{.AppUrl}}user/activate?code={{.Code}}</a></p> | |||
<p>Not working? Try copying and pasting it to your browser.</p> | |||
</div> | |||
<p class="copyright text grey">© 2015 <a target="_blank" href="http://gogs.io">Gogs: Go Git Service</a></p> | |||
</body> | |||
</html> |
@@ -1,39 +1,45 @@ | |||
{{template "ng/base/head" .}} | |||
{{template "ng/base/header" .}} | |||
<div id="sign-wrapper"> | |||
<form class="form-align form panel sign-panel sign-form container panel-radius" id="sign-up-form" action="{{AppSubUrl}}/user/activate" method="post"> | |||
{{template "base/head" .}} | |||
<div class="user activate"> | |||
<div class="ui middle very relaxed page grid"> | |||
<div class="column"> | |||
<form class="ui form" action="{{AppSubUrl}}/user/activate" method="post"> | |||
{{.CsrfTokenHtml}} | |||
<div class="panel-header"> | |||
<h2>{{.i18n.Tr "auth.active_your_account"}}</h2> | |||
</div> | |||
<div class="panel-content"> | |||
{{if .IsActivatePage}} | |||
<h2 class="ui top attached header"> | |||
{{.i18n.Tr "auth.active_your_account"}} | |||
</h2> | |||
<div class="ui attached segment"> | |||
{{if .IsActivatePage}} | |||
{{if .ServiceNotEnabled}} | |||
<p>{{.i18n.Tr "auth.disable_register_mail"}}</p> | |||
{{else if .ResendLimited}} | |||
<p>{{.i18n.Tr "auth.resent_limit_prompt"}}</p> | |||
{{else}} | |||
<p>{{.i18n.Tr "auth.confirmation_mail_sent_prompt" .SignedUser.Email .Hours | Str2html}}</p> | |||
<hr/> | |||
<label></label> | |||
<a class="btn btn-green btn-large btn-link btn-radius" href="http://{{Mail2Domain .SignedUser.Email}}">{{.i18n.Tr "auth.sign_in_email"}}</a> | |||
<div class="ui divider"></div> | |||
<div class="text right"> | |||
<a class="ui green button" href="http://{{Mail2Domain .SignedUser.Email}}">{{.i18n.Tr "auth.sign_in_to_account"}}</a> | |||
</div> | |||
{{end}} | |||
{{else}} | |||
{{else}} | |||
{{if .IsSendRegisterMail}} | |||
<p>{{.i18n.Tr "auth.confirmation_mail_sent_prompt" .Email .Hours | Str2html}}</p> | |||
<hr/> | |||
<label></label> | |||
<a class="btn btn-green btn-large btn-link btn-radius" href="http://{{Mail2Domain .Email}}">{{.i18n.Tr "auth.sign_in_to_account"}}</a> | |||
<div class="ui divider"></div> | |||
<div class="text right"> | |||
<a class="ui green button" href="http://{{Mail2Domain .Email}}">{{.i18n.Tr "auth.sign_in_to_account"}}</a> | |||
</div> | |||
{{else if .IsActivateFailed}} | |||
<p>{{.i18n.Tr "auth.invalid_code"}}</p> | |||
{{else}} | |||
<p>{{.i18n.Tr "auth.has_unconfirmed_mail" .SignedUser.Name .SignedUser.Email | Str2html}}</p> | |||
<hr/> | |||
<label></label> | |||
<button class="btn btn-blue btn-large btn-radius">{{.i18n.Tr "auth.resend_mail"}}</button> | |||
<div class="ui divider"></div> | |||
<div class="text right"> | |||
<button class="ui blue button" href="http://{{Mail2Domain .SignedUser.Email}}">{{.i18n.Tr "auth.resend_mail"}}</button> | |||
</div> | |||
{{end}} | |||
{{end}} | |||
{{end}} | |||
</div> | |||
</form> | |||
</form> | |||
</div> | |||
</div> | |||
</div> | |||
{{template "ng/base/footer" .}} | |||
{{template "base/footer" .}} |