Skip to content

Commit

Permalink
throw an exception when csrf_token is not found closes #4084
Browse files Browse the repository at this point in the history
  • Loading branch information
stevestmartin committed Apr 13, 2010
1 parent 59dd91d commit ac78a11
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/rails.js
Expand Up @@ -89,16 +89,17 @@ jQuery(function ($) {
form = $('<form method="post" action="'+href+'"></form>'),
metadata_input = '<input name="_method" value="'+method+'" type="hidden" />';

if (csrf_param != null && csrf_token != null) {
if (csrf_param && csrf_token) {
metadata_input += '<input name="'+csrf_param+'" value="'+csrf_token+'" type="hidden" />';
form.hide()
.append(metadata_input)
.appendTo('body')
.submit();
} else {
throw "No CSRF token found (is csrf_meta_tag in your layout?).";
}

form.hide()
.append(metadata_input)
.appendTo('body');

e.preventDefault();
form.submit();
});

/**
Expand Down

0 comments on commit ac78a11

Please sign in to comment.