mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-09 11:30:00 +00:00
Update after testrun
This commit is contained in:
parent
99e50bafc4
commit
c09e1ed203
@ -30,8 +30,9 @@ from flask_dance.consumer import oauth_authorized, oauth_error
|
||||
from flask_dance.contrib.github import make_github_blueprint, github
|
||||
from flask_dance.contrib.google import make_google_blueprint, google
|
||||
from oauthlib.oauth2 import TokenExpiredError, InvalidGrantError
|
||||
from .cw_login import login_user, current_user, login_required
|
||||
from .cw_login import login_user, current_user
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
from .usermanagement import user_login_required
|
||||
|
||||
from . import constants, logger, config, app, ub
|
||||
|
||||
|
@ -129,8 +129,7 @@ def feed_best_rated():
|
||||
|
||||
|
||||
@opds.route("/opds/hot")
|
||||
#@requires_basic_auth_if_no_ano
|
||||
@auth.login_required
|
||||
@requires_basic_auth_if_no_ano
|
||||
def feed_hot():
|
||||
if not auth.current_user().check_visibility(constants.SIDEBAR_HOT):
|
||||
abort(404)
|
||||
@ -154,8 +153,7 @@ def feed_hot():
|
||||
|
||||
|
||||
@opds.route("/opds/author")
|
||||
#@requires_basic_auth_if_no_ano
|
||||
@auth.login_required
|
||||
@requires_basic_auth_if_no_ano
|
||||
def feed_authorindex():
|
||||
if not auth.current_user().check_visibility(constants.SIDEBAR_AUTHOR):
|
||||
abort(404)
|
||||
@ -163,8 +161,7 @@ def feed_authorindex():
|
||||
|
||||
|
||||
@opds.route("/opds/author/letter/<book_id>")
|
||||
#@requires_basic_auth_if_no_ano
|
||||
@auth.login_required
|
||||
@requires_basic_auth_if_no_ano
|
||||
def feed_letter_author(book_id):
|
||||
if not auth.current_user().check_visibility(constants.SIDEBAR_AUTHOR):
|
||||
abort(404)
|
||||
|
17
cps/ub.py
17
cps/ub.py
@ -574,6 +574,21 @@ def add_missing_tables(engine, _session):
|
||||
Thumbnail.__table__.create(bind=engine)
|
||||
|
||||
|
||||
# migrate all settings missing in registration table
|
||||
def migrate_registration_table(engine, _session):
|
||||
try:
|
||||
# Handle table exists, but no content
|
||||
cnt = _session.query(Registration).count()
|
||||
if not cnt:
|
||||
with engine.connect() as conn:
|
||||
trans = conn.begin()
|
||||
conn.execute(text("insert into registration (domain, allow) values('%.%',1)"))
|
||||
trans.commit()
|
||||
except exc.OperationalError: # Database is not writeable
|
||||
print('Settings database is not writeable. Exiting...')
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
def migrate_user_session_table(engine, _session):
|
||||
try:
|
||||
_session.query(exists().where(User_Sessions.random)).scalar()
|
||||
@ -592,6 +607,7 @@ def migrate_user_session_table(engine, _session):
|
||||
def migrate_Database(_session):
|
||||
engine = _session.bind
|
||||
add_missing_tables(engine, _session)
|
||||
migrate_registration_table(engine, _session)
|
||||
migrate_user_session_table(engine, _session)
|
||||
|
||||
|
||||
@ -603,6 +619,7 @@ def clean_database(_session):
|
||||
_session.commit()
|
||||
|
||||
|
||||
|
||||
# Save downloaded books per user in calibre-web's own database
|
||||
def update_download(book_id, user_id):
|
||||
check = session.query(Downloads).filter(Downloads.user_id == user_id).filter(Downloads.book_id == book_id).first()
|
||||
|
@ -40,6 +40,7 @@ def verify_password(username, password):
|
||||
if user.name.lower() == "guest":
|
||||
if config.config_anonbrowse == 1:
|
||||
return user
|
||||
limiter.check()
|
||||
if config.config_login_type == constants.LOGIN_LDAP and services.ldap:
|
||||
login_result, error = services.ldap.bind_user(user.name, password)
|
||||
if login_result:
|
||||
@ -89,8 +90,6 @@ def login_required_if_no_ano(func):
|
||||
if user:
|
||||
g.flask_httpauth_user = user
|
||||
return func(*args, **kwargs)
|
||||
# proxy_auth.set_user(user)
|
||||
# return proxy_auth.login_required(func)(*args, **kwargs)
|
||||
g.flask_httpauth_user = None
|
||||
if config.config_anonbrowse == 1:
|
||||
return func(*args, **kwargs)
|
||||
@ -127,8 +126,6 @@ def load_user_from_reverse_proxy_header(req):
|
||||
|
||||
@lm.user_loader
|
||||
def load_user(user_id, random, session_key):
|
||||
# log.info(f"user {user_id}, random {random}")
|
||||
# log.info(request)
|
||||
user = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()
|
||||
if random and session_key:
|
||||
entry = ub.session.query(ub.User_Sessions).filter(ub.User_Sessions.random == random,
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user