summary refs log tree commit diff stats
path: root/rails/app/controllers
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-12-10 11:38:57 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2022-12-10 11:39:29 -0500
commit0b4d3fbc200e646eed48a1a919dde9ee03678688 (patch)
tree123fed7ecf90a22618a8814ecca60d0e48567fb6 /rails/app/controllers
parent0380a97230023a78ad08b738c4520e901485ed63 (diff)
downloadlingo-0b4d3fbc200e646eed48a1a919dde9ee03678688.tar.gz
lingo-0b4d3fbc200e646eed48a1a919dde9ee03678688.tar.bz2
lingo-0b4d3fbc200e646eed48a1a919dde9ee03678688.zip
Bot can submit to scoreboard now
Also updated the scoreboard styling

refs #13
Diffstat (limited to 'rails/app/controllers')
-rw-r--r--rails/app/controllers/lingo/scores_controller.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/rails/app/controllers/lingo/scores_controller.rb b/rails/app/controllers/lingo/scores_controller.rb index 63fd0f9..59bbd9d 100644 --- a/rails/app/controllers/lingo/scores_controller.rb +++ b/rails/app/controllers/lingo/scores_controller.rb
@@ -1,5 +1,7 @@
1module Lingo 1module Lingo
2 class ScoresController < ApplicationController 2 class ScoresController < ApplicationController
3 skip_before_action :verify_authenticity_token, only: [:update]
4
3 def index 5 def index
4 @scores = Score.order(score: :desc) 6 @scores = Score.order(score: :desc)
5 end 7 end
@@ -8,13 +10,15 @@ module Lingo
8 if params[:secret_code] != Lingo.secret_code then 10 if params[:secret_code] != Lingo.secret_code then
9 head :unauthorized 11 head :unauthorized
10 else 12 else
11 score = Score.find_or_create_by(user_id: params[:user_id]) 13 score = Score.find_or_create_by(user_id: params[:user_id]) do |score|
14 score.score = 0
15 end
12 score.username = params[:username] 16 score.username = params[:username]
13 score.avatar_url = params[:avatar_url] 17 score.avatar_url = CGI.unescape(params[:avatar_url])
14 score.score += 1 18 score.score += 1
15 score.save! 19 score.save!
16 20
17 render :blank 21 head :created
18 end 22 end
19 end 23 end
20 end 24 end