Finished register.

This commit is contained in:
2025-01-24 21:19:03 +01:00
parent be9489f939
commit 2ba55f692d
12 changed files with 129 additions and 70 deletions
+3 -2
View File
@@ -1,13 +1,14 @@
from snek.system.service import BaseService
from snek.system import security
class UserService:
class UserService(BaseService):
mapper_name = "user"
async def create_user(self, username, password):
async def register(self, email, username, password):
if await self.exists(username=username):
raise Exception("User already exists.")
model = await self.new()
model.email = email
model.username = username
model.password = await security.hash(password)
if await self.save(model):