|
@ -99,12 +99,10 @@ class User(db.Model): |
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True) |
|
|
id = db.Column(db.Integer, primary_key=True) |
|
|
username = db.Column(db.String(100)) |
|
|
username = db.Column(db.String(100)) |
|
|
password = db.Column(db.String(128)) |
|
|
|
|
|
authenticated = db.Column(db.Boolean, default=False) |
|
|
authenticated = db.Column(db.Boolean, default=False) |
|
|
|
|
|
|
|
|
def __init__(self, username, password): |
|
|
|
|
|
|
|
|
def __init__(self, username): |
|
|
self.username = username |
|
|
self.username = username |
|
|
self.password = password |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
@staticmethod |
|
|
def try_login(username, password): |
|
|
def try_login(username, password): |
|
@ -199,14 +197,10 @@ def login(): |
|
|
return redirect(url_for('index')) |
|
|
return redirect(url_for('index')) |
|
|
|
|
|
|
|
|
form = LoginForm(request.form) |
|
|
form = LoginForm(request.form) |
|
|
print(form) |
|
|
|
|
|
print(request.method) |
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST' and form.validate(): |
|
|
if request.method == 'POST' and form.validate(): |
|
|
username = request.form.get('username') |
|
|
username = request.form.get('username') |
|
|
password = request.form.get('password') |
|
|
password = request.form.get('password') |
|
|
print(username) |
|
|
|
|
|
print(password) |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
User.try_login(username, password) |
|
|
User.try_login(username, password) |
|
@ -218,9 +212,8 @@ def login(): |
|
|
|
|
|
|
|
|
user = User.query.filter(User.username == username).first() |
|
|
user = User.query.filter(User.username == username).first() |
|
|
|
|
|
|
|
|
print(user) |
|
|
|
|
|
if user is None: |
|
|
if user is None: |
|
|
user = User(username, password) |
|
|
|
|
|
|
|
|
user = User(username) |
|
|
db.session.add(user) |
|
|
db.session.add(user) |
|
|
user.authenticated = True |
|
|
user.authenticated = True |
|
|
db.session.commit() |
|
|
db.session.commit() |
|
|