From 99912d4ab54f92f384b81d05d2be98df5911a88e Mon Sep 17 00:00:00 2001
From: kaiyou <pierre@jaury.eu>
Date: Sat, 14 Sep 2019 12:20:45 +0200
Subject: [PATCH] Fix the management cli to support uuids

---
 trurt/manage.py | 6 +++---
 trurt/models.py | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/trurt/manage.py b/trurt/manage.py
index 87aac60c..9c550eb4 100644
--- a/trurt/manage.py
+++ b/trurt/manage.py
@@ -30,12 +30,12 @@ def create_user(username, password):
 
 @trurt.command()
 @click.argument("username")
-@click.argument("spn")
+@click.argument("service_uuid")
 @click.argument("profile_username")
 @flask_cli.with_appcontext
-def create_profile(username, spn, profile_username):
+def create_profile(username, service_uuid, profile_username):
     user = models.User.query.filter_by(username=username).first()
-    service = models.Service.query.filter_by(spn=spn).first()
+    service = models.Service.query.get(service_uuid)
     profile = models.Profile()
     profile.user = user
     profile.service = service
diff --git a/trurt/models.py b/trurt/models.py
index b65fcac9..31b6868f 100644
--- a/trurt/models.py
+++ b/trurt/models.py
@@ -74,15 +74,15 @@ class User(db.Model):
         user = cls.query.filter_by(username=username).first()
         if not user:
             return False
-        auth = Auth.query.filter_by(user_id=user.id).first()
-        if not auth:
+        auths = user.auths
+        if not auths:
             return False
-        if not auth.check_password(password):
+        if not auths[0].check_password(password):
             return False
         return user
 
     def get_id(self):
-        return self.id
+        return self.uuid
 
     def get_default_profile(self, service):
         profile = Profile()
-- 
GitLab