blob: 823e2a7bf0a9e32dcf609db4592404cb4bfc532b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
|