Finished register.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user