From 6a33b290a09b623bfb85d0bc03b2c7e6524ecf2d Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 25 Jul 2021 08:09:52 +0100 Subject: Fix add authentication page (#16543) * Fix add authentication page There is a regression in #16199 whereby the add authentication page fails to react to the change in selected type. This is due to the String() method on the LoginSourceType which is ameliorated with an Int() function being added. Following on from this there are a few other related bugs. Fix #16541 Signed-off-by: Andrew Thornton --- models/login_source.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'models') diff --git a/models/login_source.go b/models/login_source.go index 5e1c6e2224..3a48074e9a 100644 --- a/models/login_source.go +++ b/models/login_source.go @@ -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)", @@ -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 @@ -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 -- cgit v1.2.3