mirror of
https://github.com/hrfee/jellyfin-accounts.git
synced 2025-12-20 01:01:13 +00:00
Speed up interface through adding caching
jf_api now caches the list of users, only fetching new data if the cache is more than 30 minutes old. Also remove the pointless tempJF with an instance named auth_jf since jf_api can now handle multiple authentications.
This commit is contained in:
@@ -11,13 +11,11 @@ from __main__ import auth_log as log
|
||||
from jellyfin_accounts.jf_api import Jellyfin
|
||||
from jellyfin_accounts.web_api import jf
|
||||
|
||||
|
||||
def tempJF():
|
||||
return Jellyfin(config['jellyfin']['server'],
|
||||
config['jellyfin']['client'],
|
||||
config['jellyfin']['version'],
|
||||
config['jellyfin']['device'] + '_temp',
|
||||
config['jellyfin']['device_id'] + '_temp')
|
||||
auth_jf = Jellyfin(config['jellyfin']['server'],
|
||||
config['jellyfin']['client'],
|
||||
config['jellyfin']['version'],
|
||||
config['jellyfin']['device'],
|
||||
config['jellyfin']['device_id'] + '_authClient')
|
||||
|
||||
class Account():
|
||||
def __init__(self, username=None, password=None):
|
||||
@@ -35,9 +33,8 @@ class Account():
|
||||
if not self.jf:
|
||||
return pwd_context.verify(password, self.password_hash)
|
||||
else:
|
||||
temp_jf = tempJF()
|
||||
try:
|
||||
return temp_jf.authenticate(self.username, password)
|
||||
return auth_jf.authenticate(self.username, password)
|
||||
except Jellyfin.AuthenticationError:
|
||||
return False
|
||||
def generate_token(self, expiration=1200):
|
||||
@@ -107,7 +104,6 @@ def verify_password(username, password):
|
||||
else:
|
||||
user = accounts['adminAccount']
|
||||
verified = Account().verify_token(username, accounts)
|
||||
|
||||
if not verified:
|
||||
if username == user.username and user.verify_password(password):
|
||||
g.user = user
|
||||
|
||||
Reference in New Issue
Block a user