diff --git a/save_account.py b/save_account.py new file mode 100644 index 0000000..b2a323e --- /dev/null +++ b/save_account.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +""" +Account save/create functionality for inlinegui. +Supports saving user info (Name, Email) from Mozilla Persona +or collecting via a simple form. +""" +import json +import os +from datetime import datetime + +DATA_FILE = os.environ.get('INLINEGUI_DATA', 'accounts.json') + +def load_accounts(): + """Load accounts from JSON file.""" + if os.path.exists(DATA_FILE): + with open(DATA_FILE, 'r') as f: + return json.load(f) + return {} + +def save_accounts(accounts): + """Save accounts to JSON file.""" + with open(DATA_FILE, 'w') as f: + json.dump(accounts, f, indent=2) + +def save_user_info(name, email): + """Save user info from Mozilla Persona or similar auth.""" + accounts = load_accounts() + if email in accounts: + accounts[email]['name'] = name + accounts[email]['updated_at'] = datetime.utcnow().isoformat() + else: + accounts[email] = { + 'name': name, + 'email': email, + 'created_at': datetime.utcnow().isoformat() + } + save_accounts(accounts) + return accounts[email] + +def get_create_account_html(): + """Return HTML for a simple account creation form (Stripe-inspired minimal style).""" + return """ + +
+ + +Get started with InlineGUI
+ +