import uuid
from typing import Optional
from fastapi import  Request
from fastapi_users import UUIDIDMixin, BaseUserManager
from fastapi_users.jwt import SecretType

from src.database.user import User

SECRET: SecretType

class UserManager(UUIDIDMixin, BaseUserManager[User, uuid.UUID]):

    def __init__(self, secret: SecretType):
        super().__init__()

    reset_password_token_secret = SECRET
    verification_token_secret = SECRET

    async def on_after_register(self, user: User, request: Optional[Request] = None):
        print(f"User {user.id} has registered.")

    async def on_after_forgot_password(
        self, user: User, token: str, request: Optional[Request] = None
    ):
        print(f"User {user.id} has forgot their password. Reset token: {token}")

    async def on_after_request_verify(
        self, user: User, token: str, request: Optional[Request] = None
    ):
        print(f"Verification requested for user {user.id}. Verification token: {token}")