diff options
-rw-r--r-- | cmd/web.go | 4 | ||||
-rw-r--r-- | conf/app.ini | 3 | ||||
-rwxr-xr-x | conf/locale/locale_fr-CA.ini | 44 | ||||
-rw-r--r-- | gogs.go | 2 | ||||
-rw-r--r-- | models/user.go | 2 | ||||
-rw-r--r-- | modules/mailer/mailer.go | 60 | ||||
-rw-r--r-- | modules/setting/setting.go | 10 | ||||
-rw-r--r-- | routers/user/auth.go | 2 | ||||
-rw-r--r-- | routers/user/home.go | 6 | ||||
-rw-r--r-- | templates/.VERSION | 2 |
10 files changed, 88 insertions, 47 deletions
@@ -75,8 +75,8 @@ func checkVersion() { // Check dependency version. checkers := []VerChecker{ {"github.com/Unknwon/macaron", macaron.Version, "0.4.7"}, - {"github.com/macaron-contrib/binding", binding.Version, "0.0.2"}, - {"github.com/macaron-contrib/i18n", i18n.Version, "0.0.3"}, + {"github.com/macaron-contrib/binding", binding.Version, "0.0.3"}, + {"github.com/macaron-contrib/i18n", i18n.Version, "0.0.4"}, {"github.com/macaron-contrib/session", session.Version, "0.0.5"}, } for _, c := range checkers { diff --git a/conf/app.ini b/conf/app.ini index 1c7c70be..d6ee6ae4 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -94,7 +94,10 @@ SUBJECT = %(APP_NAME)s ; Mail server ; Gmail: smtp.gmail.com:587 ; QQ: smtp.qq.com:25 +; Note, if the port ends with "465", SMTPS will be used. Using STARTTLS on port 587 is recommended per RFC 6409. If the server supports STARTTLS it will always be used. HOST = +; Do not verify the certificate of the server. Only use this for self-signed certificates +SKIP_VERIFY = ; Mail from address FROM = ; Mailer user name and password diff --git a/conf/locale/locale_fr-CA.ini b/conf/locale/locale_fr-CA.ini index d8cb1877..4f710b00 100755 --- a/conf/locale/locale_fr-CA.ini +++ b/conf/locale/locale_fr-CA.ini @@ -377,29 +377,29 @@ diff.stats_desc=<strong> %d fichiers modifiés</strong> avec <strong>%d ajouts</ diff.bin=BIN
diff.view_file=Voir le fichier
-release.releases=Releases
-release.new_release=New Release
-release.draft=Draft
-release.prerelease=Pre-Release
+release.releases=Versions
+release.new_release=Nouvelle version
+release.draft=Brouillon
+release.prerelease=Pré-publication
release.stable=Stable
-release.edit=edit
-release.ahead=<strong>%d</strong> commits to %s since this release
-release.source_code=Source Code
-release.tag_name=Tag name
-release.target=Target
-release.tag_helper=Choose an existing tag, or create a new tag on publish.
-release.release_title=Release title
-release.content_with_md=Content with <a href="%s">Markdown</a>
-release.write=Write
-release.preview=Preview
-release.content_placeholder=Write some content
-release.loading=Loading...
-release.prerelease_desc=This is a pre-release
-release.prerelease_helper=We’ll point out that this release is identified as non-production ready.
-release.publish=Publish Release
-release.save_draft=Save Draft
-release.edit_release=Edit Release
-release.tag_name_already_exist=Release with this tag name has already existed.
+release.edit=Éditer
+release.ahead=<strong>%d</strong> commissions à %s depuis cette publication
+release.source_code=Code Source
+release.tag_name=Nom du tag
+release.target=Cible
+release.tag_helper=Choisissez un tag existant ou créez-en un nouveau à publier.
+release.release_title=Titre de la publication
+release.content_with_md=Contenu avec <a href="%s">Démarque(s)</a>
+release.write=Écrire
+release.preview=Prévisualiser
+release.content_placeholder=Rédiger du contenu
+release.loading=Chargement…
+release.prerelease_desc=Il s'agit d'une version préliminaire
+release.prerelease_helper=Nous soulignerons que cette version est considérée comme non prête pour la production.
+release.publish=Publier
+release.save_draft=Sauvegarder le Brouillon
+release.edit_release=Éditer la publication
+release.tag_name_already_exist=Une publication avec ce nom de tag a déjà existée.
[org]
org_name_holder=Nom d'organisation
@@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.9.1216 Beta" +const APP_VER = "0.5.9.1217 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/user.go b/models/user.go index 631a0274..2537a3e6 100644 --- a/models/user.go +++ b/models/user.go @@ -453,7 +453,7 @@ func ChangeUserName(u *User, newUserName string) (err error) { // UpdateUser updates user's information. func UpdateUser(u *User) error { - has, err := x.Where("id != ?", u.Id).And("email = ?", u.Email).Get(new(User)) + has, err := x.Where("id!=?", u.Id).And("email=?", u.Email).Get(new(User)) if err != nil { return err } else if has { diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go index 474e1481..f17e5c27 100644 --- a/modules/mailer/mailer.go +++ b/modules/mailer/mailer.go @@ -67,27 +67,61 @@ func processMailQueue() { } // sendMail allows mail with self-signed certificates. -func sendMail(hostAddressWithPort string, auth smtp.Auth, from string, recipients []string, msgContent []byte) error { - client, err := smtp.Dial(hostAddressWithPort) +func sendMail(settings *setting.Mailer, from string, recipients []string, msgContent []byte) error { + host, port, err := net.SplitHostPort(settings.Host) if err != nil { return err } - host, _, _ := net.SplitHostPort(hostAddressWithPort) - tlsConn := &tls.Config{ - InsecureSkipVerify: true, + tlsconfig := &tls.Config{ + InsecureSkipVerify: settings.SkipVerify, ServerName: host, } - if err = client.StartTLS(tlsConn); err != nil { + + conn, err := net.Dial("tcp", net.JoinHostPort(host, port)) + if err != nil { return err } + defer conn.Close() - if ok, _ := client.Extension("AUTH"); ok && auth != nil { - if err = client.Auth(auth); err != nil { + isSecureConn := false + // Start TLS directly if the port ends with 465 (SMTPS protocol) + if strings.HasSuffix(port, "465") { + conn = tls.Client(conn, tlsconfig) + isSecureConn = true + } + + client, err := smtp.NewClient(conn, host) + if err != nil { + return err + } + + // If not using SMTPS, alway use STARTTLS if available + hasStartTLS, _ := client.Extension("STARTTLS") + if !isSecureConn && hasStartTLS { + if err = client.StartTLS(tlsconfig); err != nil { return err } } + canAuth, options := client.Extension("AUTH") + + if canAuth && len(settings.User) > 0 { + var auth smtp.Auth + + if strings.Contains(options, "CRAM-MD5") { + auth = smtp.CRAMMD5Auth(settings.User, settings.Passwd) + } else if strings.Contains(options, "PLAIN") { + auth = smtp.PlainAuth("", settings.User, settings.Passwd, host) + } + + if auth != nil { + if err = client.Auth(auth); err != nil { + return err + } + } + } + if err = client.Mail(from); err != nil { return err } @@ -116,7 +150,6 @@ func sendMail(hostAddressWithPort string, auth smtp.Auth, from string, recipient // Direct Send mail message func Send(msg *Message) (int, error) { log.Trace("Sending mails to: %s", strings.Join(msg.To, "; ")) - host := strings.Split(setting.MailService.Host, ":") // get message body content := msg.Content() @@ -127,17 +160,12 @@ func Send(msg *Message) (int, error) { return 0, fmt.Errorf("empty email body") } - var auth smtp.Auth - if len(setting.MailService.Passwd) > 0 { - auth = smtp.PlainAuth("", setting.MailService.User, setting.MailService.Passwd, host[0]) - } - 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.Host, auth, msg.From, []string{to}, body) + err := sendMail(setting.MailService, msg.From, []string{to}, body) if err != nil { return num, err } @@ -148,7 +176,7 @@ func Send(msg *Message) (int, error) { body := []byte("To: " + strings.Join(msg.To, ";") + "\r\n" + content) // send to multiple emails in one message - err := sendMail(setting.MailService.Host, auth, msg.From, msg.To, body) + err := sendMail(setting.MailService, msg.From, msg.To, body) if err != nil { return 0, err } else { diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 7765a859..76e1ab76 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -437,6 +437,7 @@ type Mailer struct { Host string From string User, Passwd string + SkipVerify bool } type OauthInfo struct { @@ -463,10 +464,11 @@ func newMailService() { } MailService = &Mailer{ - Name: Cfg.MustValue("mailer", "NAME", AppName), - Host: Cfg.MustValue("mailer", "HOST"), - User: Cfg.MustValue("mailer", "USER"), - Passwd: Cfg.MustValue("mailer", "PASSWD"), + Name: Cfg.MustValue("mailer", "NAME", AppName), + Host: Cfg.MustValue("mailer", "HOST"), + User: Cfg.MustValue("mailer", "USER"), + Passwd: Cfg.MustValue("mailer", "PASSWD"), + SkipVerify: Cfg.MustBool("mailer", "SKIP_VERIFY", false), } MailService.From = Cfg.MustValue("mailer", "FROM", MailService.User) log.Info("Mail Service Enabled") diff --git a/routers/user/auth.go b/routers/user/auth.go index a5b27453..9ed44e35 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -62,6 +62,8 @@ func SignIn(ctx *middleware.Context) { if err != nil { if err != models.ErrUserNotExist { ctx.Handle(500, "GetUserByName", err) + } else { + ctx.HTML(200, SIGNIN) } return } diff --git a/routers/user/home.go b/routers/user/home.go index f5f6ab94..1aabe087 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -105,6 +105,9 @@ func Dashboard(ctx *middleware.Context) { // FIXME: cache results? u, err := models.GetUserByName(act.ActUserName) if err != nil { + if err == models.ErrUserNotExist { + continue + } ctx.Handle(500, "GetUserByName", err) return } @@ -210,6 +213,9 @@ func Profile(ctx *middleware.Context) { // FIXME: cache results? u, err := models.GetUserByName(act.ActUserName) if err != nil { + if err == models.ErrUserNotExist { + continue + } ctx.Handle(500, "GetUserByName", err) return } diff --git a/templates/.VERSION b/templates/.VERSION index e72ad157..a4d3f0f9 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.9.1216 Beta
\ No newline at end of file +0.5.9.1217 Beta
\ No newline at end of file |