Skip to content

Fix add authentication page #16543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions models/login_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func (typ LoginType) String() string {
return LoginNames[typ]
}

// Int returns the int value of the LoginType
func (typ LoginType) Int() int {
return int(typ)
}

// LoginNames contains the name of LoginType values.
var LoginNames = map[LoginType]string{
LoginLDAP: "LDAP (via BindDN)",
Expand Down Expand Up @@ -218,6 +223,10 @@ func CreateLoginSource(source *LoginSource) error {
return nil
}

if settable, ok := source.Cfg.(LoginSourceSettable); ok {
settable.SetLoginSource(source)
}

registerableSource, ok := source.Cfg.(RegisterableSource)
if !ok {
return nil
Expand Down Expand Up @@ -320,6 +329,10 @@ func UpdateSource(source *LoginSource) error {
return nil
}

if settable, ok := source.Cfg.(LoginSourceSettable); ok {
settable.SetLoginSource(source)
}

registerableSource, ok := source.Cfg.(RegisterableSource)
if !ok {
return nil
Expand Down
5 changes: 5 additions & 0 deletions services/auth/source/ldap/security_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ func (s SecurityProtocol) String() string {
return SecurityProtocolNames[s]
}

// Int returns the int value of the SecurityProtocol
func (s SecurityProtocol) Int() int {
return int(s)
}

// SecurityProtocolNames contains the name of SecurityProtocol values.
var SecurityProtocolNames = map[SecurityProtocol]string{
SecurityProtocolUnencrypted: "Unencrypted",
Expand Down
4 changes: 2 additions & 2 deletions templates/admin/auth/edit.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<input type="hidden" name="id" value="{{.Source.ID}}">
<div class="inline field">
<label>{{$.i18n.Tr "admin.auths.auth_type"}}</label>
<input type="hidden" id="auth_type" name="type" value="{{.Source.Type}}">
<input type="hidden" id="auth_type" name="type" value="{{.Source.Type.Int}}">
<span>{{.Source.TypeName}}</span>
</div>
<div class="required inline field {{if .Err_Name}}error{{end}}">
Expand All @@ -31,7 +31,7 @@
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu">
{{range .SecurityProtocols}}
<div class="item" data-value="{{.Type}}">{{.Name}}</div>
<div class="item" data-value="{{.Type.Int}}">{{.Name}}</div>
{{end}}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/admin/auth/new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<div class="inline required field {{if .Err_Type}}error{{end}}">
<label>{{.i18n.Tr "admin.auths.auth_type"}}</label>
<div class="ui selection type dropdown">
<input type="hidden" id="auth_type" name="type" value="{{.type}}">
<input type="hidden" id="auth_type" name="type" value="{{.type.Int}}">
<div class="text">{{.CurrentTypeName}}</div>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu">
{{range .AuthSources}}
<div class="item" data-value="{{.Type}}">{{.Name}}</div>
<div class="item" data-value="{{.Type.Int}}">{{.Name}}</div>
{{end}}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/auth/source/ldap.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu">
{{range .SecurityProtocols}}
<div class="item" data-value="{{.Type}}">{{.Name}}</div>
<div class="item" data-value="{{.Type.Int}}">{{.Name}}</div>
{{end}}
</div>
</div>
Expand Down