diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-03-27 13:33:34 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-03-27 13:33:34 -0400 |
| commit | f090feb8d4cacce9a1e8ffcda6cb542917c7e1e1 (patch) | |
| tree | 0b4e9df9a05d7adac4abe162d9692b6047d685b1 /app/controllers | |
railzZz
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/application_controller.rb | 3 | ||||
| -rw-r--r-- | app/controllers/finger_controller.rb | 38 |
2 files changed, 41 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..bf99b83 --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + protect_from_forgery +end diff --git a/app/controllers/finger_controller.rb b/app/controllers/finger_controller.rb new file mode 100644 index 0000000..823e2a7 --- /dev/null +++ b/app/controllers/finger_controller.rb @@ -0,0 +1,38 @@ +class FingerController < ApplicationController + + http_basic_authenticate_with :name => "dumpfm", :password => "jazzcup", :except => :create + + def create + @finger = Finger.new() + @finger.remote_addr = request.remote_ip + @finger.nick = params[:nick] + @finger.token = params[:token] + + @lookup = Finger.where(:token => @finger.token, :nick => @finger.nick).first + + if @lookup + render :json => { 'status' => @lookup.banned ? 'KO' : 'OK' } + elsif @finger.save + render :json => { 'status' => 'OK' } + else + render :json => { 'status' => 'ERROR' } + end + end + + def index + @fingers = Finger.all + end + + def ban + @finger = Finger.find(params[:id]) + + @finger.banned = (params[:banned] == "true") + + if @finger.save + render :json => { 'status' => 'OK' } + else + render :json => { 'status' => 'ERROR' } + end + end + +end |
