Mappers and models.

This commit is contained in:
2025-01-25 22:24:44 +01:00
parent bb6bcf41d1
commit b4f9ff2c62
27 changed files with 413 additions and 40 deletions
+5 -2
View File
@@ -7,10 +7,8 @@ class UserService(BaseService):
async def validate_login(self, username, password):
model = await self.get(username=username)
print("FOUND USER!", model, flush=True)
if not model:
return False
print("AU", password, model.password.value, flush=True)
if not await security.verify(password, model["password"]):
return False
return True
@@ -19,9 +17,14 @@ class UserService(BaseService):
if await self.exists(username=username):
raise Exception("User already exists.")
model = await self.new()
model['nick'] = username
model.email.value = email
model.username.value = username
model.password.value = await security.hash(password)
if await self.save(model):
if model:
channel = await self.services.channel.ensure_public_channel(model['uid'])
if not channel:
raise Exception("Failed to create public channel.")
return model
raise Exception(f"Failed to create user: {model.errors}.")