Created
April 19, 2019 17:59
-
-
Save saghaulor/e57e28d627ef399529937e979c3ebfe6 to your computer and use it in GitHub Desktop.
A sample controller and route demonstrating CSRF vulnerabilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AcountsController < ApplicationController | |
before_action :set_current_user | |
def transfer | |
from_account = Account.find(owner_id: current_user.id) | |
to_account = Account.find(id: params(:to_id) | |
AccountTransferService.call(from: from_account, to: to_account, amount: params(:amount)) | |
end | |
end | |
Rails.application.routes.draw do | |
match "accounts/transfer", to: "accounts#transfer", via [:get, :post] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment