mirror of
https://github.com/janeczku/calibre-web
synced 2025-11-07 18:54:03 +00:00
Working again (basically)
This commit is contained in:
27
cps/ub.py
27
cps/ub.py
@@ -23,7 +23,6 @@ from sqlalchemy import exc
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import *
|
||||
from flask_login import AnonymousUserMixin
|
||||
from flask_dance.consumer.backend.sqla import OAuthConsumerMixin
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
@@ -69,6 +68,10 @@ AUTO_UPDATE_STABLE = 1
|
||||
UPDATE_NIGHTLY = 2
|
||||
AUTO_UPDATE_NIGHTLY = 4
|
||||
|
||||
engine = create_engine('sqlite:///{0}'.format(cli.settingspath), echo=False)
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
class UserBase:
|
||||
|
||||
@property
|
||||
@@ -171,13 +174,13 @@ class UserBase:
|
||||
return '<User %r>' % self.nickname
|
||||
|
||||
#Login via LDAP method
|
||||
@staticmethod
|
||||
''''@staticmethod
|
||||
def try_login(username, password):
|
||||
conn = get_ldap_connection()
|
||||
conn.simple_bind_s(
|
||||
config.config_ldap_dn.replace("%s", username),
|
||||
password
|
||||
)
|
||||
)'''
|
||||
|
||||
# Baseclass for Users in Calibre-Web, settings which are depending on certain users are stored here. It is derived from
|
||||
# User Base (all access methods are declared there)
|
||||
@@ -197,11 +200,11 @@ class User(UserBase, Base):
|
||||
default_language = Column(String(3), default="all")
|
||||
mature_content = Column(Boolean, default=True)
|
||||
|
||||
|
||||
'''
|
||||
class OAuth(OAuthConsumerMixin, Base):
|
||||
provider_user_id = Column(String(256))
|
||||
user_id = Column(Integer, ForeignKey(User.id))
|
||||
user = relationship(User)
|
||||
user = relationship(User)'''
|
||||
|
||||
|
||||
# Class for anonymous user is derived from User base and completly overrides methods and properties for the
|
||||
@@ -815,7 +818,7 @@ def delete_download(book_id):
|
||||
session.commit()
|
||||
|
||||
# Generate user Guest (translated text), as anoymous user, no rights
|
||||
def create_anonymous_user():
|
||||
def create_anonymous_user(session):
|
||||
user = User()
|
||||
user.nickname = "Guest"
|
||||
user.email = 'no@email'
|
||||
@@ -852,7 +855,7 @@ Session = sessionmaker()
|
||||
Session.configure(bind=engine)
|
||||
session = Session()
|
||||
|
||||
# generate database and admin and guest user, if no database is existing
|
||||
|
||||
if not os.path.exists(cli.settingspath):
|
||||
try:
|
||||
Base.metadata.create_all(engine)
|
||||
@@ -865,13 +868,3 @@ else:
|
||||
Base.metadata.create_all(engine)
|
||||
migrate_Database()
|
||||
clean_database()
|
||||
|
||||
#get LDAP connection
|
||||
def get_ldap_connection():
|
||||
import ldap
|
||||
conn = ldap.initialize('ldap://{}'.format(config.config_ldap_provider_url))
|
||||
return conn
|
||||
|
||||
# Generate global Settings Object accessible from every file
|
||||
config = Config()
|
||||
searched_ids = {}
|
||||
|
||||
Reference in New Issue
Block a user