Skip to content

Commit

Permalink
Verify CSRF token for reads_controller (forem#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhao-Andy authored and benhalpern committed Apr 6, 2018
1 parent 02cff62 commit f0b3e65
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/assets/javascripts/initializers/initNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ function markNotificationsAsRead() {
}
xmlhttp.onreadystatechange = function () {
};

var csrfToken = document.querySelector("meta[name='csrf-token']").content;

xmlhttp.open('Post', '/notifications/reads', true);
xmlhttp.setRequestHeader('X-CSRF-Token', csrfToken);
xmlhttp.send();
}
}, 120);
Expand Down
1 change: 0 additions & 1 deletion app/controllers/notifications/reads_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class Notifications::ReadsController < ApplicationController
skip_before_action :verify_authenticity_token
skip_before_action :ensure_signup_complete
def create
result = ""
Expand Down

0 comments on commit f0b3e65

Please sign in to comment.