From 0b869ccb89547f066cf7cfaceddb83f5419b396c Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 6 Apr 2018 12:00:45 +0630 Subject: [PATCH] cehck mobile --- app/controllers/base_origami_controller.rb | 29 +++++++++++++++------- app/controllers/origami/home_controller.rb | 1 - 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index b627ae01..64441590 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -16,8 +16,23 @@ class BaseOrigamiController < ActionController::Base end def check_user - if current_user.nil? - redirect_to root_path + token_status = false + authenticate_with_http_token do |token, options| + if token + token_status = true + session[:webview] = true + session[:session_token] = token + end + end + + if token_status + if current_user.nil? + redirect_to root_path + end + else + if current_user.nil? + redirect_to root_path + end end end @@ -38,13 +53,9 @@ class BaseOrigamiController < ActionController::Base #check webview def check_mobile status = false - authenticate_with_http_token do |token, options| - if token - session[:webview] = true - end - session[:session_token] = token - end - + puts "check mobile" + puts session[:session_token] + puts session[:webview] if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i status = true end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 5ed006a1..79a86ea9 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -7,7 +7,6 @@ class Origami::HomeController < BaseOrigamiController if check_mobile @webview = true end - @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))