mirror of
https://github.com/janeczku/calibre-web
synced 2025-11-14 14:17:10 +00:00
User and admin pages are working again
This commit is contained in:
22
cps/ub.py
22
cps/ub.py
@@ -23,6 +23,7 @@ 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
|
||||
@@ -32,6 +33,11 @@ import datetime
|
||||
from binascii import hexlify
|
||||
import cli
|
||||
|
||||
try:
|
||||
import ldap
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
engine = create_engine('sqlite:///{0}'.format(cli.settingspath), echo=False)
|
||||
Base = declarative_base()
|
||||
|
||||
@@ -176,13 +182,12 @@ 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
|
||||
)'''
|
||||
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)
|
||||
@@ -202,11 +207,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
|
||||
@@ -776,6 +781,13 @@ def clean_database():
|
||||
session.query(RemoteAuthToken).filter(now > RemoteAuthToken.expiration).delete()
|
||||
|
||||
|
||||
#get LDAP connection
|
||||
def get_ldap_connection():
|
||||
conn = ldap.initialize('ldap://{}'.format(config.config_ldap_provider_url))
|
||||
return conn
|
||||
|
||||
|
||||
|
||||
def create_default_config():
|
||||
settings = Settings()
|
||||
settings.mail_server = "mail.example.com"
|
||||
|
||||
Reference in New Issue
Block a user