Make --auth.method parameter optional Fixes: #715

This commit is contained in:
cnone 2019-05-19 17:13:34 +03:00
parent 88500ab219
commit 6e48a6b512
2 changed files with 8 additions and 1 deletions

View File

@ -44,8 +44,11 @@ func addConfigFlags(flags *pflag.FlagSet) {
flags.Bool("branding.disableExternal", false, "disable external links such as GitHub links")
}
func getAuthentication(flags *pflag.FlagSet) (settings.AuthMethod, auth.Auther) {
func getAuthentication(flags *pflag.FlagSet, defaults ...*settings.Settings) (settings.AuthMethod, auth.Auther) {
method := settings.AuthMethod(mustGetString(flags, "auth.method"))
if len(defaults) > 0 {
method = defaults[0].AuthMethod
}
var auther auth.Auther
if method == auth.MethodProxyAuth {

View File

@ -71,6 +71,10 @@ you want to change. Other options will remain unchanged.`,
} else {
auther, err = d.store.Auth.Get(set.AuthMethod)
checkErr(err)
// check if there are new flags for existing auth method
set.AuthMethod, auther = getAuthentication(flags, set)
err = d.store.Auth.Save(auther)
checkErr(err)
}
err = d.store.Settings.Save(set)