FIX: Ask to log in before requesting who_voted (#58)

FIX: Ask to log in before requesting who_voted (#58)

/voting/who path has ensure_logged_in so clicking the vote count to see who voted triggered http requests that ended with 403 error. Now, users are asked to log in, just like when clicking the “vote” button.

diff --git a/assets/javascripts/discourse/widgets/vote-count.js.es6 b/assets/javascripts/discourse/widgets/vote-count.js.es6
index 03ddf29..803d883 100644
--- a/assets/javascripts/discourse/widgets/vote-count.js.es6
+++ b/assets/javascripts/discourse/widgets/vote-count.js.es6
@@ -40,6 +40,12 @@ export default createWidget("vote-count", {
   },
 
   click() {
+    if (!this.currentUser) {
+      this.sendWidgetAction("showLogin");
+      $.cookie("destination_url", window.location.href);
+      return;
+    }
+
     if (this.siteSettings.voting_show_who_voted && this.attrs.vote_count > 0) {
       if (this.state.whoVotedUsers === null) {
         return this.getWhoVoted();

GitHub sha: 8ebda184

This commit appears in #58 which was approved by davidtaylorhq. It was merged by CvX.