diff --git a/README.md b/README.md index 97880534..db67696d 100755 --- a/README.md +++ b/README.md @@ -228,6 +228,9 @@ For Price 0 in receipt bill For Aston Request => Gift Voucher 1) settings/payment_method_settings => {payment_method:'GiftVoucher', is_active:true, ...} +For Login expiry time + 1) settings/lookups => {type:expity_time, name:login, value: {minutes}} + * value should be minute only (30 / 60 / 120 / etc.) Menu Image (Import guideline) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index cd4d099a..3988784c 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -134,8 +134,7 @@ class Origami::HomeController < BaseOrigamiController accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC") @tax_arr =[] accounts.each do |acc| - account = TaxProfile.find(acc.id) - @tax_arr.push(account.name) + @tax_arr.push(acc.name) end lookup_spit_bill = Lookup.collection_of('split_bill') diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index cab68e3d..d81c8ce8 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -160,7 +160,6 @@ class Origami::RoomsController < BaseOrigamiController accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC") @tax_arr =[] accounts.each do |acc| - account = TaxProfile.find(acc.id) @tax_arr.push(account.name) end diff --git a/app/models/employee.rb b/app/models/employee.rb index c1f985ea..66f9a7f0 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -21,12 +21,12 @@ class Employee < ApplicationRecord def self.login(emp_id, password) user = Employee.find_by_emp_id(emp_id) + expiry_time = login_expiry_time if (user) #user.authenticate(password) - if (user.authenticate(password)) user.generate_token - user.session_expiry = DateTime.now.utc + 30.minutes + user.session_expiry = DateTime.now.utc + expiry_time.minutes user.session_last_login = DateTime.now.utc user.save return user @@ -41,9 +41,10 @@ class Employee < ApplicationRecord def self.authenticate_by_token(session_token) if (session_token) user = Employee.find_by_token_session(session_token) + expiry_time = login_expiry_time if user && user.session_expiry.utc > DateTime.now.utc #Extend the login time each time authenticatation take place - user.session_expiry = user.session_expiry.utc + 30.minutes + user.session_expiry = user.session_expiry.utc + expiry_time.minutes user.save return true else @@ -72,5 +73,17 @@ class Employee < ApplicationRecord retry end + def self.login_expiry_time + expiry_time = 30 + login_expiry = Lookup.collection_of('expiry_time') + if !login_expiry.empty? + login_expiry.each do |exp_time| + if exp_time[0].downcase == "login" + expiry_time = exp_time[1].to_i + end + end + end + return expiry_time + end end diff --git a/lib/tasks/clear_data.rake b/lib/tasks/clear_data.rake index 989e9f85..e74f4252 100755 --- a/lib/tasks/clear_data.rake +++ b/lib/tasks/clear_data.rake @@ -16,6 +16,7 @@ namespace :clear do PaymentJournal.delete_all Survey.delete_all ProductCommission.delete_all + InDuty.delete_all DiningFacility.update_all(status:'available') CashierTerminal.update_all(is_currently_login: 0) SeedGenerator.where("id > 1").update(:current => 0, :next => 1)