Skip to content

Commit eb21e71

Browse files
committed
Login Route - Updates for API GEN
1 parent 3ff8f2a commit eb21e71

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

apps/authentication/routes.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from flask_restx import Resource, Api
1010

11+
import flask
1112
from flask import render_template, redirect, request, url_for
1213
from flask_login import (
1314
current_user,
@@ -45,18 +46,20 @@ def login_github():
4546
@blueprint.route('/login', methods=['GET', 'POST'])
4647
def login():
4748
login_form = LoginForm(request.form)
48-
if 'login' in request.form:
49+
50+
if flask.request.method == 'POST':
4951

5052
# read form data
5153
username = request.form['username']
5254
password = request.form['password']
5355

56+
#return 'Login: ' + username + ' / ' + password
57+
5458
# Locate user
5559
user = Users.query.filter_by(username=username).first()
5660

5761
# Check the password
5862
if user and verify_pass(password, user.password):
59-
6063
login_user(user)
6164
return redirect(url_for('authentication_blueprint.route_default'))
6265

@@ -65,10 +68,11 @@ def login():
6568
msg='Wrong user or password',
6669
form=login_form)
6770

68-
if not current_user.is_authenticated:
71+
if current_user.is_authenticated:
72+
return redirect(url_for('home_blueprint.index'))
73+
else:
6974
return render_template('accounts/login.html',
70-
form=login_form)
71-
return redirect(url_for('home_blueprint.index'))
75+
form=login_form)
7276

7377

7478
@blueprint.route('/register', methods=['GET', 'POST'])

0 commit comments

Comments
 (0)