diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-07 04:11:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-07 04:11:27 +0100 |
commit | 69b61d437357235700306f28d22d21acc39bb2b5 (patch) | |
tree | 33af1d4d797b428556a323837fcc3eda38a54479 /cmd/admin_auth_ldap.go | |
parent | [skip ci] Updated translations via Crowdin (diff) | |
download | forgejo-69b61d437357235700306f28d22d21acc39bb2b5.tar.xz forgejo-69b61d437357235700306f28d22d21acc39bb2b5.zip |
Fix bug on admin subcommand (#17533)
* Fix bug on admin subcommand
* Add signals for all initDB
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'cmd/admin_auth_ldap.go')
-rw-r--r-- | cmd/admin_auth_ldap.go | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/cmd/admin_auth_ldap.go b/cmd/admin_auth_ldap.go index 517904957f..950d515e39 100644 --- a/cmd/admin_auth_ldap.go +++ b/cmd/admin_auth_ldap.go @@ -5,6 +5,7 @@ package cmd import ( + "context" "fmt" "strings" @@ -16,7 +17,7 @@ import ( type ( authService struct { - initDB func() error + initDB func(ctx context.Context) error createLoginSource func(loginSource *login.Source) error updateLoginSource func(loginSource *login.Source) error getLoginSourceByID func(id int64) (*login.Source, error) @@ -299,7 +300,10 @@ func (a *authService) addLdapBindDn(c *cli.Context) error { return err } - if err := a.initDB(); err != nil { + ctx, cancel := installSignals() + defer cancel() + + if err := a.initDB(ctx); err != nil { return err } @@ -321,7 +325,10 @@ func (a *authService) addLdapBindDn(c *cli.Context) error { // updateLdapBindDn updates a new LDAP via Bind DN authentication source. func (a *authService) updateLdapBindDn(c *cli.Context) error { - if err := a.initDB(); err != nil { + ctx, cancel := installSignals() + defer cancel() + + if err := a.initDB(ctx); err != nil { return err } @@ -344,7 +351,10 @@ func (a *authService) addLdapSimpleAuth(c *cli.Context) error { return err } - if err := a.initDB(); err != nil { + ctx, cancel := installSignals() + defer cancel() + + if err := a.initDB(ctx); err != nil { return err } @@ -366,7 +376,10 @@ func (a *authService) addLdapSimpleAuth(c *cli.Context) error { // updateLdapBindDn updates a new LDAP (simple auth) authentication source. func (a *authService) updateLdapSimpleAuth(c *cli.Context) error { - if err := a.initDB(); err != nil { + ctx, cancel := installSignals() + defer cancel() + + if err := a.initDB(ctx); err != nil { return err } |