summaryrefslogtreecommitdiffstats
path: root/bitvend
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2017-06-02 15:41:00 +0200
committerPiotr Dobrowolski <admin@tastycode.pl>2017-06-02 15:41:00 +0200
commit8f1d906e9c55d1620c9cad039935411136c00bac (patch)
tree6c51b8d3bf234f43861f5adf22b48d4e496d8f4f /bitvend
parent55dab93eb872ce29c872b379bf5819c9cc6d9a0a (diff)
downloadbitvend-8f1d906e9c55d1620c9cad039935411136c00bac.tar.gz
bitvend-8f1d906e9c55d1620c9cad039935411136c00bac.tar.bz2
bitvend-8f1d906e9c55d1620c9cad039935411136c00bac.tar.xz
bitvend-8f1d906e9c55d1620c9cad039935411136c00bac.zip
Remember login by default, fix horizontal scrolling
Diffstat (limited to 'bitvend')
-rw-r--r--bitvend/admin.py4
-rw-r--r--bitvend/auth.py7
-rw-r--r--bitvend/templates/base.html8
3 files changed, 17 insertions, 2 deletions
diff --git a/bitvend/admin.py b/bitvend/admin.py
index fdbab1a..24271de 100644
--- a/bitvend/admin.py
+++ b/bitvend/admin.py
@@ -1,5 +1,5 @@
from flask import Blueprint, render_template, redirect, request, flash, url_for
-from flask_login import current_user
+from flask_login import current_user, fresh_login_required
from bitvend.models import db, Transaction
from bitvend.forms import ManualForm
@@ -10,6 +10,7 @@ admin_required = cap_required('staff')
bp = Blueprint('admin', __name__)
@bp.route('/manual', methods=['GET', 'POST'])
+@fresh_login_required
@admin_required
def manual():
form = ManualForm()
@@ -24,6 +25,7 @@ def manual():
@bp.route('/transactions/', defaults={'page': 1})
@bp.route('/transactions/p/<int:page>')
+@fresh_login_required
@admin_required
def transactions(page):
return render_template('admin/transactions.html',
diff --git a/bitvend/auth.py b/bitvend/auth.py
index 8e1ff26..5ad9154 100644
--- a/bitvend/auth.py
+++ b/bitvend/auth.py
@@ -9,6 +9,11 @@ from sqlalchemy import func
login_manager = LoginManager()
+login_manager.refresh_view = "bitvend.login"
+login_manager.needs_refresh_message = (
+ u"To protect your account, please reauthenticate to access this page."
+)
+login_manager.needs_refresh_message_category = "info"
@login_manager.user_loader
def load_user(user_id):
@@ -28,7 +33,7 @@ def try_login(username, password):
db.session.add(u)
db.session.commit()
- login_user(u)
+ login_user(u, remember=True)
return True
diff --git a/bitvend/templates/base.html b/bitvend/templates/base.html
index d6d569e..d3c2c9c 100644
--- a/bitvend/templates/base.html
+++ b/bitvend/templates/base.html
@@ -36,6 +36,9 @@
opacity: 0.5;
font-style: italic;
}
+ .vend-item code {
+ word-wrap: break-word;
+ }
</style>
</head>
<body>
@@ -48,6 +51,11 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
+ {% if current_user.is_authenticated %}
+ <a href="{{ url_for('bitvend.logout') }}" class="navbar-brand pull-right hidden-md hidden-lg"><small>Logout</small></a>
+ {% else %}
+ <a href="{{ url_for('bitvend.login') }}" class="navbar-brand pull-right hidden-md hidden-lg"><small>Login</small></a>
+ {% endif %}
</div>
<div class="navbar-collapse collapse" id="navbar-main">
<p class="navbar-text navbar-nav">