cehck mobile

This commit is contained in:
phyusin
2018-04-06 12:00:45 +06:30
parent 8217b7c2f2
commit 0b869ccb89
2 changed files with 20 additions and 10 deletions

View File

@@ -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

View File

@@ -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'))