Skip to content

Magickey#77

Open
RensDimmendaal wants to merge 5 commits intomainfrom
magickey
Open

Magickey#77
RensDimmendaal wants to merge 5 commits intomainfrom
magickey

Conversation

@RensDimmendaal
Copy link
Copy Markdown
Contributor

This PR adds a helper for magic links and an example for the fasthtml magickey implementation.

@github-actions
Copy link
Copy Markdown

📖 Documentation Preview: https://plash-docs-pr-77.pla.sh

Comment thread examples/magickey_auth/main.py Outdated
from plash_cli.auth import send_magiclink

db = database('data/data.db')
users = db.t.user.create(id=int, email=str, pk='id', if_not_exists=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need if_not_exists? Also do you need to import database from fastlite?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do need it because otherwise on a second start when the database already exists it raises SQLError: table [user] already exists. I double checked the fasthtml docs and did find there's a different suggested pattern so I've moved to use that instead:

class User: id:int; email:str
class Passkey: id:str; user_id:int; public_key:bytes; sign_count:int
users = db.create(User)
passkeys = db.create(Passkey)

Re database: it's also exported from fasthtml.common so we technically dont need to include it in the imports. do you prefer we'd add it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread examples/magickey_auth/main.py Outdated
db = database('data/data.db')
users = db.t.user.create(id=int, email=str, pk='id', if_not_exists=True)
passkeys = db.t.passkey.create(id=str, user_id=int, public_key=bytes, sign_count=int, pk='id', if_not_exists=True)
User,Passkey = users.dataclass(),passkeys.dataclass()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the approach here is neater for fastlite stuff: https://github.com/AnswerDotAI/fasthtml/blob/main/examples/adv_app_strip.py

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, missed this comment, but I got to the same solution in the other thread. Thanks!

@RensDimmendaal RensDimmendaal marked this pull request as ready for review April 16, 2026 07:05
@RensDimmendaal RensDimmendaal requested a review from ncoop57 April 16, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants