From 68a65798520556ff7130d7e7e53bd260d890bb7c Mon Sep 17 00:00:00 2001 From: haixunlu Date: Thu, 13 Sep 2018 10:49:07 -0700 Subject: login_source: add default authentication switch (#5338) * Add default Authentication Switch. * adjust the code accroding to reviews * #1. Remove redudant logic. #2, Fix a bug in "Edit" panel. * Remove unused logic * Fix local authentication files are not flushed. * refactor according to review. --- routes/admin/auths.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'routes/admin/auths.go') diff --git a/routes/admin/auths.go b/routes/admin/auths.go index 49f01433..d013c793 100644 --- a/routes/admin/auths.go +++ b/routes/admin/auths.go @@ -69,6 +69,7 @@ func NewAuthSource(c *context.Context) { c.Data["CurrentSecurityProtocol"] = models.SecurityProtocolNames[ldap.SECURITY_PROTOCOL_UNENCRYPTED] c.Data["smtp_auth"] = "PLAIN" c.Data["is_active"] = true + c.Data["is_default"] = true c.Data["AuthSources"] = authSources c.Data["SecurityProtocols"] = securityProtocols c.Data["SMTPAuths"] = models.SMTPAuths @@ -152,6 +153,7 @@ func NewAuthSourcePost(c *context.Context, f form.Authentication) { Type: models.LoginType(f.Type), Name: f.Name, IsActived: f.IsActive, + IsDefault: f.IsDefault, Cfg: config, }); err != nil { if models.IsErrLoginSourceAlreadyExist(err) { @@ -225,11 +227,13 @@ func EditAuthSourcePost(c *context.Context, f form.Authentication) { source.Name = f.Name source.IsActived = f.IsActive + source.IsDefault = f.IsDefault source.Cfg = config if err := models.UpdateLoginSource(source); err != nil { c.ServerError("UpdateLoginSource", err) return } + log.Trace("Authentication changed by admin '%s': %d", c.User.Name, source.ID) c.Flash.Success(c.Tr("admin.auths.update_success")) -- cgit v1.2.3