about summary refs log tree commit diff stats
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c9d4e15..ad46fb9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb
@@ -1,19 +1,19 @@
1class ApplicationController < ActionController::Base 1class ApplicationController < ActionController::Base
2 protect_from_forgery with: :exception 2 protect_from_forgery with: :exception
3 3 before_action :choose_random_song
4 protected
5
6 def authenticate_pokeviewer(login, token)
7 user = login && User.find_by_login(login)
8
9 ActiveSupport::SecurityUtils.secure_compare(
10 ::Digest::SHA256.hexdigest(user.pokeviewer_token),
11 ::Digest::SHA256.hexdigest(token))
12 end
13 4
14 private 5 private
15 6
16 def after_sign_out_path_for(resource) 7 def after_sign_out_path_for(resource)
17 new_session_path(resource) 8 new_session_path(resource)
18 end 9 end
10
11 def choose_random_song
12 ids = Scrobble.ids
13 if ids.empty?
14 @random_song = nil
15 else
16 @random_song = Scrobble.find(ids.sample)
17 end
18 end
19end 19end