Ver código fonte

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 4 anos atrás
pai
commit
b60ae1edc0
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados ID da chave GPG: D6F1633A4F0903B8
1 arquivos alterados com 18 adições e 0 exclusões
  1. +18
    -0
      api/api.go

+ 18
- 0
api/api.go Ver arquivo

@@ -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() {


Carregando…
Cancelar
Salvar