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.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

2
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

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
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
}
}

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>
<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>
{{if .DefaultLoginSource}}
{{.DefaultLoginSource.Name}}
{{else}}
<span class="text">
{{.i18n.Tr "auth.local"}}
{{end}}
</span>
<i class="dropdown icon"></i>
<div class="menu">
@ -45,7 +36,6 @@
<div class="item" data-value="{{.ID}}">{{.Name}}</div>
{{end}}
</div>
{{end}}
</div>
</div>
{{end}}

Loading…
Cancel
Save