Closes #2 and #3

This commit is contained in:
Punnamaraju Vinayaka Tejas 2023-07-12 12:51:39 +05:30
parent f52d98333e
commit de094d4bed
4 changed files with 13 additions and 6 deletions

View file

@ -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'),
REGISTER=False
)
app.wsgi_app = ProxyFix(

View file

@ -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, abort
)
from werkzeug.security import check_password_hash, generate_password_hash
@ -11,6 +11,8 @@ bp = Blueprint('auth', __name__, url_prefix='/auth')
@bp.route('/register', methods=('GET', 'POST'))
def register():
if not current_app.config['REGISTER']:
abort(403)
if request.method == 'POST':
username = request.form['username']
password = request.form['password']

View file

@ -8,9 +8,6 @@
{% if g.user %}
<li><span>{{ g.user['username'] }}</span>
<li><a href="{{ url_for('auth.logout') }}">Log Out</a>
{% else %}
<li><a href="{{ url_for('auth.register') }}">Register</a>
<li><a href="{{ url_for('auth.login') }}">Log In</a>
{% endif %}
</ul>
</nav>