flask 0.11 compatibility

このコミットが含まれているのは:
Stephane Martin 2016-09-05 23:19:28 +02:00
コミット d7d8ef6d76
5個のファイルの変更13行の追加13行の削除

ファイルの表示

@ -224,7 +224,7 @@ def create_app(config=None):
from realms.modules.auth.proxy.models import User as ProxyUser from realms.modules.auth.proxy.models import User as ProxyUser
remote_user = request.environ.get(app.config["AUTH_PROXY_HEADER_NAME"]) remote_user = request.environ.get(app.config["AUTH_PROXY_HEADER_NAME"])
if remote_user: if remote_user:
if current_user.is_authenticated(): if current_user.is_authenticated:
if current_user.id == remote_user: if current_user.id == remote_user:
return return
logger.info("login in realms and login by proxy are different: '{}'/'{}'".format( logger.info("login in realms and login by proxy are different: '{}'/'{}'".format(

ファイルの表示

@ -12,7 +12,7 @@ blueprint = Blueprint('auth', __name__, template_folder='templates')
@blueprint.route("/login", methods=['GET', 'POST']) @blueprint.route("/login", methods=['GET', 'POST'])
def login(): def login():
next_url = request.args.get('next') or url_for(current_app.config['ROOT_ENDPOINT']) next_url = request.args.get('next') or url_for(current_app.config['ROOT_ENDPOINT'])
if current_user.is_authenticated(): if current_user.is_authenticated:
return redirect(next_url) return redirect(next_url)
session['next_url'] = next_url session['next_url'] = next_url
return render_template("auth/login.html", forms=Auth.login_forms()) return render_template("auth/login.html", forms=Auth.login_forms())

ファイルの表示

@ -11,7 +11,7 @@ blueprint = Blueprint('search', __name__, template_folder='templates')
@blueprint.route('/_search') @blueprint.route('/_search')
def search(): def search():
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous:
return current_app.login_manager.unauthorized() return current_app.login_manager.unauthorized()
results = search_engine.wiki(request.args.get('q')) results = search_engine.wiki(request.args.get('q'))

ファイルの表示

@ -17,7 +17,7 @@ blueprint = Blueprint('wiki', __name__, template_folder='templates',
@blueprint.route("/_commit/<sha>/<path:name>") @blueprint.route("/_commit/<sha>/<path:name>")
def commit(name, sha): def commit(name, sha):
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous:
return current_app.login_manager.unauthorized() return current_app.login_manager.unauthorized()
cname = to_canonical(name) cname = to_canonical(name)
@ -32,7 +32,7 @@ def commit(name, sha):
@blueprint.route(r"/_compare/<path:name>/<regex('\w+'):fsha><regex('\.{2,3}'):dots><regex('\w+'):lsha>") @blueprint.route(r"/_compare/<path:name>/<regex('\w+'):fsha><regex('\.{2,3}'):dots><regex('\w+'):lsha>")
def compare(name, fsha, dots, lsha): def compare(name, fsha, dots, lsha):
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous:
return current_app.login_manager.unauthorized() return current_app.login_manager.unauthorized()
diff = g.current_wiki.get_page(name, sha=lsha).compare(fsha) diff = g.current_wiki.get_page(name, sha=lsha).compare(fsha)
@ -47,7 +47,7 @@ def revert():
commit = request.form.get('commit') commit = request.form.get('commit')
message = request.form.get('message', "Reverting %s" % cname) message = request.form.get('message', "Reverting %s" % cname)
if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous(): if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous:
return dict(error=True, message="Anonymous posting not allowed"), 403 return dict(error=True, message="Anonymous posting not allowed"), 403
if cname in current_app.config.get('WIKI_LOCKED_PAGES'): if cname in current_app.config.get('WIKI_LOCKED_PAGES'):
@ -69,7 +69,7 @@ def revert():
@blueprint.route("/_history/<path:name>") @blueprint.route("/_history/<path:name>")
def history(name): def history(name):
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous:
return current_app.login_manager.unauthorized() return current_app.login_manager.unauthorized()
return render_template('wiki/history.html', name=name) return render_template('wiki/history.html', name=name)
@ -77,7 +77,7 @@ def history(name):
@blueprint.route("/_history_data/<path:name>") @blueprint.route("/_history_data/<path:name>")
def history_data(name): def history_data(name):
"""Ajax provider for paginated history data.""" """Ajax provider for paginated history data."""
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous:
return current_app.login_manager.unauthorized() return current_app.login_manager.unauthorized()
draw = int(request.args.get('draw', 0)) draw = int(request.args.get('draw', 0))
start = int(request.args.get('start', 0)) start = int(request.args.get('start', 0))
@ -171,7 +171,7 @@ def _tree_index(items, path=""):
@blueprint.route("/_index", defaults={"path": ""}) @blueprint.route("/_index", defaults={"path": ""})
@blueprint.route("/_index/<path:path>") @blueprint.route("/_index/<path:path>")
def index(path): def index(path):
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous:
return current_app.login_manager.unauthorized() return current_app.login_manager.unauthorized()
items = g.current_wiki.get_index() items = g.current_wiki.get_index()
@ -192,7 +192,7 @@ def page_write(name):
if not cname: if not cname:
return dict(error=True, message="Invalid name") return dict(error=True, message="Invalid name")
if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous(): if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous:
return dict(error=True, message="Anonymous posting not allowed"), 403 return dict(error=True, message="Anonymous posting not allowed"), 403
if request.method == 'POST': if request.method == 'POST':
@ -235,7 +235,7 @@ def page_write(name):
@blueprint.route("/", defaults={'name': 'home'}) @blueprint.route("/", defaults={'name': 'home'})
@blueprint.route("/<path:name>") @blueprint.route("/<path:name>")
def page(name): def page(name):
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous:
return current_app.login_manager.unauthorized() return current_app.login_manager.unauthorized()
cname = to_canonical(name) cname = to_canonical(name)

ファイルの表示

@ -58,7 +58,7 @@
</div> </div>
</form> </form>
</li> </li>
{% if current_user.is_authenticated() %} {% if current_user.is_authenticated %}
<li class="dropdown user-avatar"> <li class="dropdown user-avatar">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span> <span>
@ -113,7 +113,7 @@
{% endfor %} {% endfor %}
var User = {}; var User = {};
User.is_authenticated = {{ current_user.is_authenticated()|tojson }}; User.is_authenticated = {{ current_user.is_authenticated|tojson }};
{% for attr in ['username', 'email'] %} {% for attr in ['username', 'email'] %}
User.{{ attr }} = {{ current_user[attr]|tojson }}; User.{{ attr }} = {{ current_user[attr]|tojson }};
{% endfor %} {% endfor %}