from datetime import timedelta

from pydantic import UUID4
from wattle.core.utils.auth import create_encoded_jwt
from wattle.worker.config import config

EMAIL_VERIFY_TOKEN_EXPIRES = timedelta(days=int(config.EMAIL_VERIFY_JWT_EXPIRES_DAYS))
EMAIL_PASSWORD_RESET_TOKEN_EXPIRES = timedelta(
    hours=int(config.EMAIL_PASSWORD_RESET_JWT_EXPIRES_HOURS)
)


def create_verify_token(id: UUID4) -> str:
    return create_encoded_jwt(
        data={"sub": str(id)},
        jwt_secret=config.EMAIL_VERIFY_JWT_SECRET.get_secret_value(),
        expires_delta=EMAIL_VERIFY_TOKEN_EXPIRES,
    )


def create_password_reset_token(id: UUID4, hashed_password: str) -> str:
    return create_encoded_jwt(
        data={"sub": str(id)},
        jwt_secret=<PASSWORD>,
        expires_delta=EMAIL_PASSWORD_RESET_TOKEN_EXPIRES,
    )

from datetime import timedelta

from pydantic import UUID4
from wattle.core.utils.auth import create_encoded_jwt
from wattle.worker.config import config

EMAIL_VERIFY_TOKEN_EXPIRES = timedelta(days=int(config.EMAIL_VERIFY_JWT_EXPIRES_DAYS))
EMAIL_PASSWORD_RESET_TOKEN_EXPIRES = timedelta(
    hours=int(config.EMAIL_PASSWORD_RESET_JWT_EXPIRES_HOURS)
)


def create_verify_token(id: UUID4) -> str:
    return create_encoded_jwt(
        data={"sub": str(id)},
        jwt_secret=config.EMAIL_VERIFY_JWT_SECRET.get_secret_value(),
        expires_delta=EMAIL_VERIFY_TOKEN_EXPIRES,
    )


def create_password_reset_token(id: UUID4, hashed_password: str) -> str:
    return create_encoded_jwt(
        data={"sub": str(id)},
        jwt_secret=<PASSWORD>,
        expires_delta=EMAIL_PASSWORD_RESET_TOKEN_EXPIRES,
    )
