Browse Source

auth: support set default login source (#5274)

pull/5380/merge
Unknwon 6 years ago
parent
commit
b68de2330d
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 2
      conf/locale/locale_en-US.ini
  2. 2
      gogs.go
  3. 4
      pkg/bindata/bindata.go
  4. 9
      routes/user/auth.go
  5. 2
      templates/.VERSION
  6. 16
      templates/user/auth/login.tmpl

2
conf/locale/locale_en-US.ini

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

2
gogs.go

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

4
pkg/bindata/bindata.go

File diff suppressed because one or more lines are too long

9
routes/user/auth.go

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

2
templates/.VERSION

@ -1 +1 @@
0.11.63.0910 0.11.64.0913

16
templates/user/auth/login.tmpl

@ -22,21 +22,12 @@
<label for="password">{{.i18n.Tr "auth.auth_source"}}</label> <label for="password">{{.i18n.Tr "auth.auth_source"}}</label>
<div class="ui selection dropdown"> <div class="ui selection dropdown">
<input type="hidden" id="login_source" name="login_source" value="{{.login_source}}" required> <input type="hidden" id="login_source" name="login_source" value="{{.login_source}}" required>
{{if .DefaultSource}}
<span class="text"> <span class="text">
{{.DefaultSource.Name}} {{if .DefaultLoginSource}}
</span> {{.DefaultLoginSource.Name}}
<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}} {{else}}
<span class="text">
{{.i18n.Tr "auth.local"}} {{.i18n.Tr "auth.local"}}
{{end}}
</span> </span>
<i class="dropdown icon"></i> <i class="dropdown icon"></i>
<div class="menu"> <div class="menu">
@ -45,7 +36,6 @@
<div class="item" data-value="{{.ID}}">{{.Name}}</div> <div class="item" data-value="{{.ID}}">{{.Name}}</div>
{{end}} {{end}}
</div> </div>
{{end}}
</div> </div>
</div> </div>
{{end}} {{end}}

Loading…
Cancel
Save