Переглянути джерело

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 роки тому
джерело
коміт
b60ae1edc0
Не вдалося знайти GPG ключ що відповідає даному підпису Ідентифікатор GPG ключа: D6F1633A4F0903B8
1 змінених файлів з 18 додано та 0 видалено
  1. +18
    -0
      api/api.go

+ 18
- 0
api/api.go Переглянути файл

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


Завантаження…
Відмінити
Зберегти