Procházet zdrojové kódy

get tokens for update and delete

this changes DoUpdate and DoDelete to load the user and set the access
token in the client when no edit token is provided.
pull/36/head
Rob Loranger před 4 roky
rodič
revize
b60ae1edc0
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: D6F1633A4F0903B8
1 změnil soubory, kde provedl 18 přidání a 0 odebrání
  1. +18
    -0
      api/api.go

+ 18
- 0
api/api.go Zobrazit soubor

@@ -225,6 +225,15 @@ func DoUpdate(c *cli.Context, post []byte, friendlyID, token, font string, code
return fmt.Errorf("%v", err)
}

if token == "" {
u, _ := config.LoadUser(c)
if u != nil {
cl.SetToken(u.AccessToken)
} else {
return fmt.Errorf("You must either provide and edit token or log in to delete a post.")
}
}

params := writeas.PostParams{}
params.Title, params.Content = posts.ExtractTitle(string(post))
if lang := config.Language(c, false); lang != "" {
@@ -251,6 +260,15 @@ func DoDelete(c *cli.Context, friendlyID, token string) error {
return fmt.Errorf("%v", err)
}

if token == "" {
u, _ := config.LoadUser(c)
if u != nil {
cl.SetToken(u.AccessToken)
} else {
return fmt.Errorf("You must either provide and edit token or log in to delete a post.")
}
}

err = cl.DeletePost(friendlyID, token)
if err != nil {
if config.Debug() {


Načítá se…
Zrušit
Uložit