Browse Source

auth: support set default login source (#5274)

Unknwon 5 years ago
parent
commit
b68de2330d
6 changed files with 19 additions and 32 deletions
  1. 2 0
      conf/locale/locale_en-US.ini
  2. 1 1
      gogs.go
  3. 0 0
      pkg/bindata/bindata.go
  4. 2 7
      routes/user/auth.go
  5. 1 1
      templates/.VERSION
  6. 13 23
      templates/user/auth/login.tmpl

+ 2 - 0
conf/locale/locale_en-US.ini

@@ -1102,6 +1102,7 @@ auths.new = Add New Source
 auths.name = Name
 auths.type = Type
 auths.enabled = Enabled
+auths.default = Default
 auths.updated = Updated
 auths.auth_type = Authentication Type
 auths.auth_name = Authentication Name
@@ -1140,6 +1141,7 @@ auths.pam_service_name = PAM Service Name
 auths.enable_auto_register = Enable Auto Registration
 auths.edit = Edit Authentication Setting
 auths.activated = This authentication is activated
+auths.default_auth =  This authentication is default login source
 auths.new_success = New authentication '%s' has been added successfully.
 auths.update_success = Authentication setting has been updated successfully.
 auths.update = Update Authentication Setting

+ 1 - 1
gogs.go

@@ -16,7 +16,7 @@ import (
 	"github.com/gogs/gogs/pkg/setting"
 )
 
-const APP_VER = "0.11.63.0910"
+const APP_VER = "0.11.64.0913"
 
 func init() {
 	setting.AppVer = APP_VER

File diff suppressed because it is too large
+ 0 - 0
pkg/bindata/bindata.go


+ 2 - 7
routes/user/auth.go

@@ -115,10 +115,8 @@ func Login(c *context.Context) {
 	c.Data["LoginSources"] = loginSources
 	for i := range loginSources {
 		if loginSources[i].IsDefault {
-			c.Data["DefaultSource"] = *loginSources[i]
+			c.Data["DefaultLoginSource"] = loginSources[i]
 			c.Data["login_source"] = loginSources[i].ID
-			newLoginSources := append(loginSources[:i], loginSources[i+1:]...)
-			c.Data["LoginSources"] = newLoginSources
 			break
 		}
 	}
@@ -183,10 +181,7 @@ func LoginPost(c *context.Context, f form.SignIn) {
 		}
 		for i := range loginSources {
 			if loginSources[i].IsDefault {
-				c.Data["DefaultSource"] = *loginSources[i]
-				c.Data["login_source"] = loginSources[i].ID
-				newLoginSources := append(loginSources[:i], loginSources[i+1:]...)
-				c.Data["LoginSources"] = newLoginSources
+				c.Data["DefaultLoginSource"] = loginSources[i]
 				break
 			}
 		}

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.11.63.0910
+0.11.64.0913

+ 13 - 23
templates/user/auth/login.tmpl

@@ -22,30 +22,20 @@
 							<label for="password">{{.i18n.Tr "auth.auth_source"}}</label>
 							<div class="ui selection dropdown">
 								<input type="hidden" id="login_source" name="login_source" value="{{.login_source}}" required>
-								{{if .DefaultSource}}
-									<span class="text">
-										{{.DefaultSource.Name}}
-									</span>
-									<i class="dropdown icon"></i>
-									<div class="menu">
-										<div class="item" data-value="{{.DefaultSource.ID}}">{{.DefaultSource.Name}}</div>
-										<div class="item" data-value="0">{{.i18n.Tr "auth.local"}}</div>
-										{{range .LoginSources}}
-											<div class="item" data-value="{{.ID}}">{{.Name}}</div>
-										{{end}}
-									</div>
-								{{else}}
-									<span class="text">
+								<span class="text">
+									{{if .DefaultLoginSource}}
+										{{.DefaultLoginSource.Name}}
+									{{else}}
 										{{.i18n.Tr "auth.local"}}
-									</span>
-									<i class="dropdown icon"></i>
-									<div class="menu">
-										<div class="item" data-value="0">{{.i18n.Tr "auth.local"}}</div>
-										{{range .LoginSources}}
-											<div class="item" data-value="{{.ID}}">{{.Name}}</div>
-										{{end}}
-									</div>
-								{{end}}
+									{{end}}
+								</span>
+								<i class="dropdown icon"></i>
+								<div class="menu">
+									<div class="item" data-value="0">{{.i18n.Tr "auth.local"}}</div>
+									{{range .LoginSources}}
+										<div class="item" data-value="{{.ID}}">{{.Name}}</div>
+									{{end}}
+								</div>
 							</div>
 						</div>
 					{{end}}

Some files were not shown because too many files changed in this diff