From 58f54da16b88f2600c9d53b49ae81e14facd293c Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 4 Dec 2015 05:46:53 +0100 Subject: further improved simple web interface diff --git a/importer.go b/importer.go index 8c7e66e..e47bc05 100644 --- a/importer.go +++ b/importer.go @@ -26,7 +26,7 @@ package rhimport import ( // "bytes" - "fmt" + // "fmt" // "io" // "mime/multipart" // "net/http" @@ -36,7 +36,8 @@ import ( type ImportContext struct { Conf *Config UserName string - password string + Password string + Trusted bool GroupName string Cart int Channels int @@ -51,6 +52,8 @@ func NewImportContext(conf *Config, user string, group string, cart int) *Import ctx := new(ImportContext) ctx.Conf = conf ctx.UserName = user + ctx.Password = "" + ctx.Trusted = false ctx.GroupName = group ctx.Cart = cart ctx.Channels = 2 @@ -75,7 +78,7 @@ func (ctx *ImportContext) getPassword(cached bool) (err error) { err = res.err return } - ctx.password = res.password + ctx.Password = res.password return } @@ -129,12 +132,14 @@ func (ctx *ImportContext) getPassword(cached bool) (err error) { func ImportFile(ctx *ImportContext) (err error) { rhl.Println("ImportFile called for", ctx.SourceFile) - if err = ctx.getPassword(true); err != nil { - return + if ctx.Trusted { + if err = ctx.getPassword(true); err != nil { + return + } } - rhdl.Println("credentials:", ctx.UserName, "/", ctx.password) + rhdl.Printf("credentials: '%s':'%s'", ctx.UserName, ctx.Password) - err = fmt.Errorf("%+v", ctx) +// err = fmt.Errorf("%+v", ctx) return } -- cgit v0.10.2