diff --git a/flaskr/__init__.py b/flaskr/__init__.py index ed7d989..7d7ec81 100644 --- a/flaskr/__init__.py +++ b/flaskr/__init__.py @@ -8,6 +8,7 @@ def create_app(test_config=None): app.config.from_mapping( SECRET_KEY='dev', DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'), + ALLOW_REGISTER=False, ) app.wsgi_app = ProxyFix( diff --git a/flaskr/auth.py b/flaskr/auth.py index ad930fb..6b95143 100644 --- a/flaskr/auth.py +++ b/flaskr/auth.py @@ -1,7 +1,7 @@ import functools from flask import ( - Blueprint, flash, g, redirect, render_template, request, session, url_for + Blueprint, flash, g, redirect, render_template, request, session, url_for, current_app ) from werkzeug.security import check_password_hash, generate_password_hash @@ -11,7 +11,8 @@ bp = Blueprint('auth', __name__, url_prefix='/auth') @bp.route('/register', methods=('GET', 'POST')) def register(): - # return "Admin only", 403 + if not current_app.config["ALLOW_REGISTER"]: + return "Admin only", 403 if request.method == 'POST': username = request.form['username'] password = request.form['password'] diff --git a/flaskr/templates/base.html b/flaskr/templates/base.html index 6c1d788..152f1af 100644 --- a/flaskr/templates/base.html +++ b/flaskr/templates/base.html @@ -9,7 +9,6 @@