mirror of
https://github.com/YunoHost-Apps/calibreweb_ynh.git
synced 2024-09-03 18:16:20 +02:00
Correct patches w/ vlogout
correct install script for tab add new todo
This commit is contained in:
parent
5f553d72cc
commit
2760dea36f
3 changed files with 53 additions and 45 deletions
|
@ -71,6 +71,7 @@ sudo yunohost app upgrade calibreweb -u https://github.com/Yunohost-Apps/calibre
|
|||
- [X] Package_check integration
|
||||
- [X] On backup/remove/upgrade : check for database location to update settings
|
||||
- [ ] enable magic link
|
||||
- [ ] Add cronjob to reload database
|
||||
|
||||
|
||||
## LICENSE
|
||||
|
|
|
@ -94,7 +94,7 @@ pip install --target $final_path/vendor -r $final_path/requirements.txt
|
|||
#=================================================
|
||||
#Cannot use empty string for X-script-name, causes an issue in the python prg
|
||||
if [ $path_url = "/" ] ; then
|
||||
ynh_replace_string "X-Script-Name __PATH__;" "X-Script-Name /$app;" ../conf/nginx.conf
|
||||
ynh_replace_string "X-Script-Name __PATH__;" "X-Script-Name $app;" ../conf/nginx.conf
|
||||
fi
|
||||
|
||||
# Create a dedicated nginx config
|
||||
|
|
|
@ -1,64 +1,71 @@
|
|||
--- a/cps/web.py 2019-01-12 09:01:08.000000000 +0100
|
||||
+++ b/cps/web.py 2019-01-13 15:29:45.000000000 +0100
|
||||
@@ -2360,10 +2360,27 @@
|
||||
--- ./calibre-web-Yunohost_integration/cps/web.py 2019-01-13 16:13:23.000000000 +0100
|
||||
+++ ./ori-calibre-web-master/cps/web.py 2019-01-12 09:01:08.000000000 +0100
|
||||
@@ -58,8 +58,6 @@
|
||||
import server
|
||||
from reverseproxy import ReverseProxied
|
||||
|
||||
-global vlogout
|
||||
-
|
||||
try:
|
||||
from googleapiclient.errors import HttpError
|
||||
except ImportError:
|
||||
@@ -2362,28 +2360,10 @@
|
||||
return redirect(url_for('basic_configuration'))
|
||||
if current_user is not None and current_user.is_authenticated:
|
||||
return redirect(url_for('index'))
|
||||
+ auth_user = request.headers.get('X-Remote-User')
|
||||
+ if auth_user and config.config_use_ldap:
|
||||
+ user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == auth_user.strip().lower()).first()
|
||||
+ login_user(user, remember=True)
|
||||
+ flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success")
|
||||
+ return redirect(url_for("index"))
|
||||
- auth_user = request.headers.get('X-Remote-User')
|
||||
- if auth_user and config.config_use_ldap and not vlogout:
|
||||
- vlogout = 0
|
||||
- user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == auth_user.strip().lower()).first()
|
||||
- login_user(user, remember=True)
|
||||
- flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success")
|
||||
- return redirect(url_for("index"))
|
||||
if request.method == "POST":
|
||||
form = request.form.to_dict()
|
||||
user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == form['username'].strip().lower()).first()
|
||||
- if user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest":
|
||||
+ if config.config_use_ldap and user:
|
||||
+ import ldap
|
||||
+ try:
|
||||
+ ub.User.try_login(form['username'], form['password'])
|
||||
+ login_user(user, remember=True)
|
||||
+ flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success")
|
||||
+ return redirect_back(url_for("index"))
|
||||
+ except ldap.INVALID_CREDENTIALS:
|
||||
+ ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr)
|
||||
+ app.logger.info('LDAP Login failed for user "' + form['username'] + '" IP-adress: ' + ipAdress)
|
||||
+ flash(_(u"Wrong Username or Password"), category="error")
|
||||
+ elif user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest":
|
||||
- if config.config_use_ldap and user:
|
||||
- import ldap
|
||||
- try:
|
||||
- ub.User.try_login(form['username'], form['password'])
|
||||
- login_user(user, remember=True)
|
||||
- flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success")
|
||||
- return redirect_back(url_for("index"))
|
||||
- except ldap.INVALID_CREDENTIALS:
|
||||
- ipAdress = request.headers.get('X-Forwarded-For', request.remote_addr)
|
||||
- app.logger.info('LDAP Login failed for user "' + form['username'] + '" IP-adress: ' + ipAdress)
|
||||
- flash(_(u"Wrong Username or Password"), category="error")
|
||||
- elif user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest":
|
||||
+ if user and check_password_hash(user.password, form['password']) and user.nickname is not "Guest":
|
||||
login_user(user, remember=True)
|
||||
flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.nickname), category="success")
|
||||
return redirect_back(url_for("index"))
|
||||
@@ -2384,8 +2401,9 @@
|
||||
@@ -2404,7 +2384,6 @@
|
||||
@login_required
|
||||
def logout():
|
||||
if current_user is not None and current_user.is_authenticated:
|
||||
+ logout_host = request.headers.get('Host')
|
||||
- vlogout = 1
|
||||
logout_user()
|
||||
- return redirect(url_for('login'))
|
||||
+ return redirect("https://%servername/yunohost/sso/".replace("%servername", logout_host))
|
||||
return redirect(url_for('login'))
|
||||
|
||||
|
||||
@app.route('/remote/login')
|
||||
@@ -3088,6 +3106,21 @@
|
||||
@@ -3109,21 +3088,6 @@
|
||||
if "config_ebookconverter" in to_save:
|
||||
content.config_ebookconverter = int(to_save["config_ebookconverter"])
|
||||
|
||||
+ #LDAP configuratop,
|
||||
+ if "config_use_ldap" in to_save and to_save["config_use_ldap"] == "on":
|
||||
+ if not "config_ldap_provider_url" in to_save or not "config_ldap_dn" in to_save:
|
||||
+ ub.session.commit()
|
||||
+ flash(_(u'Please enter a LDAP provider and a DN'), category="error")
|
||||
+ return render_title_template("config_edit.html", content=config, origin=origin,
|
||||
+ gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError,
|
||||
+ goodreads=goodreads_support, title=_(u"Basic Configuration"),
|
||||
+ page="config")
|
||||
+ else:
|
||||
+ content.config_use_ldap = 1
|
||||
+ content.config_ldap_provider_url = to_save["config_ldap_provider_url"]
|
||||
+ content.config_ldap_dn = to_save["config_ldap_dn"]
|
||||
+ db_change = True
|
||||
+
|
||||
- #LDAP configuratop,
|
||||
- if "config_use_ldap" in to_save and to_save["config_use_ldap"] == "on":
|
||||
- if not "config_ldap_provider_url" in to_save or not "config_ldap_dn" in to_save:
|
||||
- ub.session.commit()
|
||||
- flash(_(u'Please enter a LDAP provider and a DN'), category="error")
|
||||
- return render_title_template("config_edit.html", content=config, origin=origin,
|
||||
- gdrive=gdriveutils.gdrive_support, gdriveError=gdriveError,
|
||||
- goodreads=goodreads_support, title=_(u"Basic Configuration"),
|
||||
- page="config")
|
||||
- else:
|
||||
- content.config_use_ldap = 1
|
||||
- content.config_ldap_provider_url = to_save["config_ldap_provider_url"]
|
||||
- content.config_ldap_dn = to_save["config_ldap_dn"]
|
||||
- db_change = True
|
||||
-
|
||||
# Remote login configuration
|
||||
content.config_remote_login = ("config_remote_login" in to_save and to_save["config_remote_login"] == "on")
|
||||
if not content.config_remote_login:
|
||||
|
|
Loading…
Add table
Reference in a new issue