summary refs log tree commit diff stats
path: root/rails/app/controllers
diff options
context:
space:
mode:
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