From 96f57d52e8bc0cc821d4632e16fe2fd5dfd2bf69 Mon Sep 17 00:00:00 2001 From: Rob Loranger Date: Tue, 10 Sep 2019 08:55:09 -0700 Subject: [PATCH] fix user auth for writeas posting --- api/api.go | 2 +- config/user.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/api.go b/api/api.go index 7d77a5b..3761658 100644 --- a/api/api.go +++ b/api/api.go @@ -106,7 +106,7 @@ func DoPost(c *cli.Context, post []byte, font string, encrypt, code bool) (*writ } u, _ := config.LoadUser(c) - if u != nil && c.App.Name == "wf" { + if u != nil { cl.SetToken(u.AccessToken) } else { return nil, fmt.Errorf("Not currently logged in. Authenticate with: " + executable.Name() + " auth ") diff --git a/config/user.go b/config/user.go index 45c287d..f39cb73 100644 --- a/config/user.go +++ b/config/user.go @@ -136,6 +136,9 @@ func UserHostDir(c *cli.Context) (string, error) { // CurrentUser returns the username of the user taking action in the current // cli.Context. func CurrentUser(c *cli.Context) (string, error) { + if c.App.Name == "writeas" { + return "user", nil + } // Use user flag value if c.GlobalString("user") != "" { return c.GlobalString("user"), nil