summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application_controller.rb3
-rw-r--r--app/controllers/finger_controller.rb38
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