Skip to content

Commit

Permalink
Use new stream format
Browse files Browse the repository at this point in the history
  • Loading branch information
phuongdh committed Oct 21, 2020
1 parent 1f6874c commit c239641
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/controllers/items_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ItemsController < ApplicationController
before_action :set_item, only: [:show, :edit, :update, :destroy]
before_action :require_login, except: [:index]
before_action :require_login, except: [:index, :authorize]

def require_login
redirect_to new_user_session_path unless current_user.present?
Expand All @@ -16,7 +16,9 @@ def index
# GET /items/1.json
def show
session[:token] ||= SecureRandom.hex(16)
Rails.cache.write(session[:token], @item.streams.values, expires_in: 1.hours)
Rails.cache.write(session[:token],
@item.streams.collect { |s| s["url"] },
expires_in: 1.hours)
end

# GET /items/new
Expand Down Expand Up @@ -68,7 +70,7 @@ def destroy
end
end

# GET /items/auth
# GET /items/authorize
def authorize
authorized_streams = Rails.cache.read(params[:token])

Expand Down

0 comments on commit c239641

Please sign in to comment.