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 end
def check_user def check_user
if current_user.nil? token_status = false
redirect_to root_path 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
end end
@@ -38,13 +53,9 @@ class BaseOrigamiController < ActionController::Base
#check webview #check webview
def check_mobile def check_mobile
status = false status = false
authenticate_with_http_token do |token, options| puts "check mobile"
if token puts session[:session_token]
session[:webview] = true puts session[:webview]
end
session[:session_token] = token
end
if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i
status = true status = true
end end

View File

@@ -7,7 +7,6 @@ class Origami::HomeController < BaseOrigamiController
if check_mobile if check_mobile
@webview = true @webview = true
end end
@tables = Table.all.active.order('status desc') @tables = Table.all.active.order('status desc')
@rooms = Room.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')) @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))