from fastlite import Database
from pathlib import Path
from datetime import datetime, timedelta
import my_blog.config as config
from urllib.parse import quote, unquote
from fasthtml.common import *
from monsterui.all import *
from fasthtml_auth import AuthManager
from fasthtml.jupyter import *Notebook to update the database to add user type (local or oauth)
Run this notebook to update the database for version 3. Note, please do a pip install –update fasthtml-auth before doing so (this will update the User model)
project_root = config.PROJECT_ROOT
db_path=os.path.join(project_root, str(config.USERS_DB_PATH))
db = Database(db_path)from fasthtml_auth.models import Userfrom fastcore.utils import *src = dataclass_src(User)
hl_md(src, 'python')@dataclass
class User:
id: int | None = None
username: str | None = None
email: str | None = None
password: str | None = None
role: str = 'user'
created_at: str = ''
last_login: str = ''
active: bool = True
auth_provider: str = 'local'users = db.create(User, pk=User.pk, transform=True)users()[User(id=1, username='admin', email='confusedjohn46@gmail.com', password='$2b$12$VwfyL9lLEGy9DxnxI7n3RuzbDEBt/JPCpXUI/2mrYKTEwdT.LQxvK', role='admin', created_at='2026-02-24T17:08:39.103799', last_login='2026-03-25T14:42:20.919215', active=1, auth_provider=None)]
for user in users():
id = user.id
if not user.auth_provider:
users.update(User(id=id, auth_provider='local'))users()[User(id=1, username='admin', email='confusedjohn46@gmail.com', password='$2b$12$VwfyL9lLEGy9DxnxI7n3RuzbDEBt/JPCpXUI/2mrYKTEwdT.LQxvK', role='user', created_at='2026-04-01T19:23:06.143651', last_login='2026-04-01T19:23:06.143651', active=1, auth_provider='local')]