浏览代码

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 密钥 ID: 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() {


正在加载...
取消
保存