diff --git a/app/models/employee.rb b/app/models/employee.rb index f27adf29..1af33498 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -41,14 +41,15 @@ class Employee < ApplicationRecord 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 + expiry_time.minutes - user.save - return true - else - return false + if !user.session_expiry.nil? + 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 + expiry_time.minutes + user.save + return true + else + return false + end end end