Skip to content

Check gist ownership before editing#2034

Merged
vilmibm merged 2 commits intocli:trunkfrom
cristiand391:check-gist-ownership
Oct 5, 2020
Merged

Check gist ownership before editing#2034
vilmibm merged 2 commits intocli:trunkfrom
cristiand391:check-gist-ownership

Conversation

@cristiand391
Copy link
Copy Markdown
Contributor

Fix #1966

Copy link
Copy Markdown
Contributor

@ErKiran ErKiran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to use id instead of Login property?

username, err := api.CurrentLoginName(apiClient, ghinstance.OverridableDefault())
	if err != nil {
		return err
	}
	if username != gist.Owner.Login {
		return fmt.Errorf("You do not own this gist.")
	}

Use the id property of the owner and compare it with api.CurrentUserID(apiClient, hostname)

@hmoooda

This comment has been minimized.

@vilmibm vilmibm self-requested a review October 5, 2020 16:01
Copy link
Copy Markdown
Contributor

@vilmibm vilmibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome work, thank you!

@vilmibm vilmibm merged commit 14a5e00 into cli:trunk Oct 5, 2020
@cristiand391 cristiand391 deleted the check-gist-ownership branch October 5, 2020 22:09
Copy link
Copy Markdown

@Mercadojale Mercadojale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gist: edit command doesn't check gist ownership before editing

7 participants