summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitvend/auth.py6
-rw-r--r--bitvend/models.py4
2 files changed, 8 insertions, 2 deletions
diff --git a/bitvend/auth.py b/bitvend/auth.py
index f3a8552..f0d8d0a 100644
--- a/bitvend/auth.py
+++ b/bitvend/auth.py
@@ -5,12 +5,14 @@ from flask import session, flash, redirect, request, current_app, abort
from flask_login import login_user, LoginManager, logout_user, current_user
from flask_login.signals import user_logged_out
from bitvend.models import User, db
+from sqlalchemy import func
+
login_manager = LoginManager()
@login_manager.user_loader
def load_user(user_id):
- return User.query.filter(User.uid == user_id).first()
+ return User.find(user_id)
def try_login(username, password):
resp = requests.post('https://auth.hackerspace.pl/', data={
@@ -19,7 +21,7 @@ def try_login(username, password):
})
if resp.status_code == 200:
- u = User.query.get(username)
+ u = User.find(username)
if not u:
u = User(uid=username)
diff --git a/bitvend/models.py b/bitvend/models.py
index 89856aa..609f311 100644
--- a/bitvend/models.py
+++ b/bitvend/models.py
@@ -61,6 +61,10 @@ class User(db.Model):
def transaction_in_progress(self):
return self.transactions.filter(Transaction.finished == False).count()
+ @classmethod
+ def find(cls, uid):
+ return cls.query.filter(func.lower(cls.uid) == func.lower(uid)).first()
+
class Transaction(db.Model):
__tablename__ = 'transactions'