Do not rely on username column being lowercase always

This commit is contained in:
Ben 2020-06-05 22:48:01 +01:00
parent 2675e6b4e7
commit 6e292ac1db

View File

@ -3,6 +3,7 @@ import os
from datetime import datetime, timedelta from datetime import datetime, timedelta
import bcrypt import bcrypt
from sqlalchemy import func
from houdini import handlers from houdini import handlers
from houdini.constants import ClientType from houdini.constants import ClientType
@ -24,7 +25,7 @@ async def handle_login(p, credentials: Credentials):
username, password = credentials.username, credentials.password username, password = credentials.username, credentials.password
p.logger.info(f'{username} is logging in!') p.logger.info(f'{username} is logging in!')
data = await Penguin.query.where(Penguin.username == username).gino.first() data = await Penguin.query.where(func.lower(Penguin.username) == username).gino.first()
if data is None: if data is None:
p.logger.info(f'{username} failed to login: penguin does not exist') p.logger.info(f'{username} failed to login: penguin does not exist')