Complete system.

This commit is contained in:
2025-01-24 14:00:10 +01:00
parent ba83922660
commit d20079f3ed
39 changed files with 663 additions and 299 deletions
+16
View File
@@ -0,0 +1,16 @@
from snek.system.service import BaseService
from snek.system import security
class UserService:
mapper_name = "user"
async def create_user(self, username, password):
if await self.exists(username=username):
raise Exception("User already exists.")
model = await self.new()
model.username = username
model.password = await security.hash(password)
if await self.save(model):
return model
raise Exception(f"Failed to create user: {model.errors}.")