Unknown 10 年之前
父節點
當前提交
c5dbc24ca4
共有 4 個文件被更改,包括 38 次插入32 次删除
  1. 1 1
      gogs.go
  2. 1 3
      modules/auth/authentication.go
  3. 13 15
      routers/admin/auths.go
  4. 23 13
      templates/admin/auths/new.tmpl

+ 1 - 1
gogs.go

@@ -17,7 +17,7 @@ import (
 	"github.com/gogits/gogs/modules/base"
 	"github.com/gogits/gogs/modules/base"
 )
 )
 
 
-const APP_VER = "0.3.3.0508 Alpha"
+const APP_VER = "0.3.3.0511 Alpha"
 
 
 func init() {
 func init() {
 	base.AppVer = APP_VER
 	base.AppVer = APP_VER

+ 1 - 3
modules/auth/authentication.go

@@ -27,9 +27,7 @@ type AuthenticationForm struct {
 	MsAdSA            string `form:"ms_ad_sa"`
 	MsAdSA            string `form:"ms_ad_sa"`
 	IsActived         bool   `form:"is_actived"`
 	IsActived         bool   `form:"is_actived"`
 	SmtpAuth          string `form:"smtpauth"`
 	SmtpAuth          string `form:"smtpauth"`
-	SmtpHost          string `form:"smtphost"`
-	SmtpPort          int    `form:"smtpport"`
-	SmtpTls           bool   `form:"smtptls"`
+	Tls               bool   `form:"tls"`
 	AllowAutoRegister bool   `form:"allowautoregister"`
 	AllowAutoRegister bool   `form:"allowautoregister"`
 }
 }
 
 

+ 13 - 15
routers/admin/auths.go

@@ -5,7 +5,6 @@
 package admin
 package admin
 
 
 import (
 import (
-	"errors"
 	"strings"
 	"strings"
 
 
 	"github.com/go-martini/martini"
 	"github.com/go-martini/martini"
@@ -38,7 +37,8 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
 	}
 	}
 
 
 	var u core.Conversion
 	var u core.Conversion
-	if form.Type == models.LT_LDAP {
+	switch form.Type {
+	case models.LT_LDAP:
 		u = &models.LDAPConfig{
 		u = &models.LDAPConfig{
 			Ldapsource: ldap.Ldapsource{
 			Ldapsource: ldap.Ldapsource{
 				Host:         form.Host,
 				Host:         form.Host,
@@ -51,15 +51,16 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
 				Name:         form.AuthName,
 				Name:         form.AuthName,
 			},
 			},
 		}
 		}
-	} else if form.Type == models.LT_SMTP {
+	case models.LT_SMTP:
 		u = &models.SMTPConfig{
 		u = &models.SMTPConfig{
 			Auth: form.SmtpAuth,
 			Auth: form.SmtpAuth,
-			Host: form.SmtpHost,
-			Port: form.SmtpPort,
-			TLS:  form.SmtpTls,
+			Host: form.Host,
+			Port: form.Port,
+			TLS:  form.Tls,
 		}
 		}
-	} else {
-		panic(errors.New("not allow type"))
+	default:
+		ctx.Error(400)
+		return
 	}
 	}
 
 
 	var source = &models.LoginSource{
 	var source = &models.LoginSource{
@@ -71,10 +72,7 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
 	}
 	}
 
 
 	if err := models.AddSource(source); err != nil {
 	if err := models.AddSource(source); err != nil {
-		switch err {
-		default:
-			ctx.Handle(500, "admin.auths.NewAuth", err)
-		}
+		ctx.Handle(500, "admin.auths.NewAuth", err)
 		return
 		return
 	}
 	}
 
 
@@ -132,9 +130,9 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
 	} else if form.Type == models.LT_SMTP {
 	} else if form.Type == models.LT_SMTP {
 		config = &models.SMTPConfig{
 		config = &models.SMTPConfig{
 			Auth: form.SmtpAuth,
 			Auth: form.SmtpAuth,
-			Host: form.SmtpHost,
-			Port: form.SmtpPort,
-			TLS:  form.SmtpTls,
+			Host: form.Host,
+			Port: form.Port,
+			TLS:  form.Tls,
 		}
 		}
 	}
 	}
 
 

+ 23 - 13
templates/admin/auths/new.tmpl

@@ -82,14 +82,13 @@
                     </div>
                     </div>
 
 
                     <div class="smtp hidden">
                     <div class="smtp hidden">
-                        <div class="form-group {{if .Err_TLS}}has-error has-feedback{{end}}">
+                        <div class="form-group">
                             <label class="col-md-3 control-label">SMTP Auth: </label>
                             <label class="col-md-3 control-label">SMTP Auth: </label>
                             <div class="col-md-7">
                             <div class="col-md-7">
                                 <select name="smtpauth" class="form-control">
                                 <select name="smtpauth" class="form-control">
                                     {{range .SMTPAuths}}
                                     {{range .SMTPAuths}}
                                     <option value="{{.}}">{{.}}</option>
                                     <option value="{{.}}">{{.}}</option>
                                     {{end}}
                                     {{end}}
-                                    }
                                 </select>
                                 </select>
                             </div>
                             </div>
                         </div>
                         </div>
@@ -97,31 +96,42 @@
                         <div class="form-group {{if .Err_Host}}has-error has-feedback{{end}}">
                         <div class="form-group {{if .Err_Host}}has-error has-feedback{{end}}">
                             <label class="col-md-3 control-label">Host: </label>
                             <label class="col-md-3 control-label">Host: </label>
                             <div class="col-md-7">
                             <div class="col-md-7">
-                                <input name="smtphost" class="form-control" placeholder="Type host address" value="{{.host}}">
+                                <input name="host" class="form-control" placeholder="Type host address" value="{{.host}}">
                             </div>
                             </div>
                         </div>
                         </div>
 
 
                         <div class="form-group {{if .Err_Port}}has-error has-feedback{{end}}">
                         <div class="form-group {{if .Err_Port}}has-error has-feedback{{end}}">
                             <label class="col-md-3 control-label">Port: </label>
                             <label class="col-md-3 control-label">Port: </label>
                             <div class="col-md-7">
                             <div class="col-md-7">
-                                <input name="smtpport" class="form-control" placeholder="Type port number" value="{{.port}}">
+                                <input name="port" class="form-control" placeholder="Type port number" value="{{.port}}">
                             </div>
                             </div>
                         </div>
                         </div>
 
 
-                        <div class="form-group {{if .Err_TLS}}has-error has-feedback{{end}}">
-                            <label class="col-md-3 control-label">TLS: </label>
-                            <div class="col-md-7">
-                                <input name="smtptls" type="checkbox" class="form-control" value="">
+                        <!-- <div class="form-group">
+                            <div class="col-md-offset-3 col-md-7">
+                                <div class="checkbox">
+                                    <label>
+                                        <input name="tls" type="checkbox" {{if .tls}}checked{{end}}>
+                                        <strong>Enable Register Confirmation</strong>
+                                    </label>
+                                </div>
                             </div>
                             </div>
-                        </div>
+                        </div> -->
                     </div>
                     </div>
-                    <div class="form-group {{if .Err_TLS}}has-error has-feedback{{end}}">
-                            <label class="col-md-3 control-label">Auto Register: </label>
-                            <div class="col-md-7">
-                                <input name="allowautoregister" type="checkbox" class="form-control" value="">
+
+                    <div class="form-group">
+                        <div class="col-md-offset-3 col-md-7">
+                            <div class="checkbox">
+                                <label>
+                                    <input name="allowautoregister" type="checkbox" {{if .allowautoregister}}checked{{end}}>
+                                    <strong>Enable Auto Registeration</strong>
+                                </label>
                             </div>
                             </div>
                         </div>
                         </div>
+                    </div>
+
 					<hr/>
 					<hr/>
+
 					<div class="form-group">
 					<div class="form-group">
 					    <div class="col-md-offset-3 col-md-7">
 					    <div class="col-md-offset-3 col-md-7">
 					    	<button type="submit" class="btn btn-lg btn-primary">Create new authentication</button>
 					    	<button type="submit" class="btn btn-lg btn-primary">Create new authentication</button>