Redirect to tiny login form on /login GET

This commit is contained in:
Sage Vaillancourt 2022-09-23 18:13:43 +00:00
parent d5be15a827
commit 6ea74adc90
1 changed files with 15 additions and 6 deletions

View File

@ -63,13 +63,22 @@ class CLForm(Form):
) )
@writing_blueprint.route('/login', methods=['POST']) @writing_blueprint.route('/login', methods=['POST', 'GET'])
def login_post(): def login_post():
username = request.form['username'] if request.method == 'POST':
if db.login(username, request.form['password']): username = request.form['username']
session['username'] = username if db.login(username, request.form['password']):
return redirect('/') session['username'] = username
return make_response("", 401) return redirect('/')
return make_response("", 401)
return '''
<form method="post">
<p><input type=text name=username></p>
<p><input type=password name=password></p>
<p><input type=submit value=Login></p>
</form>
'''
@writing_blueprint.route('/', methods=['GET']) @writing_blueprint.route('/', methods=['GET'])