mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-03 06:23:10 -05:00
* Add updated recipe notification * Add recipe deleted notification * Add notifications translations * Shopping lists full c/u/d notifications * Add categories c/u/d notifications * Deal with None values in translation provider * Add tag c/u/d notifications * Add cookbook c/u/d notifications * use single key pairs for consistency with frontend * change dependency injection strategy * use generic update messages * use service to manage url generation server-side * use new strategies for messages * fix translator Co-authored-by: Miroito <alban.vachette@gmail.com>
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
from fastapi import APIRouter, HTTPException, status
|
|
|
|
from mealie.core.config import get_app_settings
|
|
from mealie.repos.all_repositories import get_repositories
|
|
from mealie.routes._base import BasePublicController, controller
|
|
from mealie.schema.response import ErrorResponse
|
|
from mealie.schema.user.registration import CreateUserRegistration
|
|
from mealie.schema.user.user import UserOut
|
|
from mealie.services.user_services.registration_service import RegistrationService
|
|
|
|
router = APIRouter(prefix="/register")
|
|
|
|
|
|
@controller(router)
|
|
class RegistrationController(BasePublicController):
|
|
@router.post("", response_model=UserOut, status_code=status.HTTP_201_CREATED)
|
|
def register_new_user(self, data: CreateUserRegistration):
|
|
settings = get_app_settings()
|
|
|
|
if not settings.ALLOW_SIGNUP and data.group_token is None or data.group_token == "":
|
|
raise HTTPException(
|
|
status_code=status.HTTP_403_FORBIDDEN,
|
|
detail=ErrorResponse.respond("User Registration is Disabled"),
|
|
)
|
|
|
|
registration_service = RegistrationService(
|
|
self.deps.logger,
|
|
get_repositories(self.deps.session),
|
|
self.translator,
|
|
)
|
|
|
|
return registration_service.register_user(data)
|