update authenticate with app_token
This commit is contained in:
@@ -38,25 +38,22 @@ class Employee < ApplicationRecord
|
||||
end
|
||||
end
|
||||
return nil
|
||||
|
||||
end
|
||||
|
||||
def self.authenticate_by_token(session_token)
|
||||
if (session_token)
|
||||
user = Employee.find_by_token_session(session_token)
|
||||
def self.authenticate_by_token(token)
|
||||
if token
|
||||
if user = Employee.find_by_token_session(token)
|
||||
expiry_time = login_expiry_time
|
||||
if user && !user.session_expiry.nil?
|
||||
if user && user.session_expiry.utc > DateTime.now.utc
|
||||
if user.session_expiry && 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
|
||||
elsif user = Employee.find_by_app_token(token)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user