mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-06-30 11:16:17 +00:00
Fix missing imports on game login
This commit is contained in:
parent
dcfd7871ed
commit
da142b2bc4
1 changed files with 5 additions and 8 deletions
|
@ -1,7 +1,9 @@
|
||||||
|
import re
|
||||||
import shortuuid
|
import shortuuid
|
||||||
|
|
||||||
from flask import Blueprint, request, jsonify
|
from flask import Blueprint, request, jsonify
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
|
from werkzeug.security import check_password_hash
|
||||||
|
|
||||||
from server.models import Scores, Sessions, Users
|
from server.models import Scores, Sessions, Users
|
||||||
from server.extensions import db
|
from server.extensions import db
|
||||||
|
@ -95,23 +97,18 @@ def login():
|
||||||
device = request.form["device"].strip()
|
device = request.form["device"].strip()
|
||||||
username_regex = re.compile(USER_REGEX)
|
username_regex = re.compile(USER_REGEX)
|
||||||
|
|
||||||
error = []
|
|
||||||
|
|
||||||
if not username or not username_regex.match(username) or not password:
|
if not username or not username_regex.match(username) or not password:
|
||||||
error.append("Username or Password is incorrect!")
|
return "Username or Password is incorrect!", 400
|
||||||
|
|
||||||
user = Users.query.filter_by(username=username).first()
|
user = Users.query.filter_by(username=username).first()
|
||||||
|
|
||||||
if not user or not check_password_hash(user.password, password):
|
if not user or not check_password_hash(user.password, password):
|
||||||
error.append("Username or Password is incorrect!")
|
return "Username or Password is incorrect!", 400
|
||||||
|
|
||||||
if error:
|
|
||||||
return jsonify(error), 400
|
|
||||||
|
|
||||||
session = Sessions(
|
session = Sessions(
|
||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
auth_key=str(shortuuid.ShortUUID().random(length=32)),
|
auth_key=str(shortuuid.ShortUUID().random(length=32)),
|
||||||
id_address=request.remote_addr,
|
ip_address=request.remote_addr,
|
||||||
device_type=device
|
device_type=device
|
||||||
)
|
)
|
||||||
db.session.add(session)
|
db.session.add(session)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue