nailed it
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -48,3 +48,6 @@ build/
|
|||||||
.examples/
|
.examples/
|
||||||
chat-summaries/
|
chat-summaries/
|
||||||
bin/
|
bin/
|
||||||
|
|
||||||
|
# Persistent data directory (contains cached tokens)
|
||||||
|
data/
|
||||||
|
|||||||
@@ -70,12 +70,29 @@ func (b *Bkosmi) Connect() error {
|
|||||||
|
|
||||||
var token string
|
var token string
|
||||||
if email != "" && password != "" {
|
if email != "" && password != "" {
|
||||||
b.Log.Info("Authenticating with email/password...")
|
// Try to load cached token first
|
||||||
token, err = loginWithChromedp(email, password, b.Log)
|
cachedToken, err := loadTokenCache(email, b.Log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("authentication failed: %w", err)
|
b.Log.Warnf("Failed to load token cache: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if cachedToken != nil {
|
||||||
|
// Use cached token
|
||||||
|
token = cachedToken.Token
|
||||||
|
} else {
|
||||||
|
// No valid cache, authenticate with browser
|
||||||
|
b.Log.Info("Authenticating with email/password...")
|
||||||
|
token, err = loginWithChromedp(email, password, b.Log)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("authentication failed: %w", err)
|
||||||
|
}
|
||||||
|
b.Log.Info("✅ Authentication successful")
|
||||||
|
|
||||||
|
// Save token to cache
|
||||||
|
if err := saveTokenCache(token, email, b.Log); err != nil {
|
||||||
|
b.Log.Warnf("Failed to cache token: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
b.Log.Info("✅ Authentication successful")
|
|
||||||
} else {
|
} else {
|
||||||
b.Log.Info("No credentials provided, using anonymous access")
|
b.Log.Info("No credentials provided, using anonymous access")
|
||||||
// token will be empty, client will get anonymous token
|
// token will be empty, client will get anonymous token
|
||||||
|
|||||||
@@ -14,12 +14,16 @@ services:
|
|||||||
- ./matterbridge.toml:/app/matterbridge.toml:ro,z
|
- ./matterbridge.toml:/app/matterbridge.toml:ro,z
|
||||||
# Optional: Mount a directory for logs
|
# Optional: Mount a directory for logs
|
||||||
- ./logs:/app/logs:z
|
- ./logs:/app/logs:z
|
||||||
|
# Mount data directory for persistent token cache
|
||||||
|
- ./data:/app/data:z
|
||||||
# If you need to expose any ports (e.g., for API or webhooks)
|
# If you need to expose any ports (e.g., for API or webhooks)
|
||||||
# ports:
|
# ports:
|
||||||
# - "4242:4242"
|
# - "4242:4242"
|
||||||
environment:
|
environment:
|
||||||
# Optional: Set timezone
|
# Optional: Set timezone
|
||||||
- TZ=America/New_York
|
- TZ=America/New_York
|
||||||
|
# Data directory for persistent storage (token cache, etc.)
|
||||||
|
- MATTERBRIDGE_DATA_DIR=/app/data
|
||||||
# Optional: Set memory limits (much lower now without browser!)
|
# Optional: Set memory limits (much lower now without browser!)
|
||||||
# mem_limit: 128m
|
# mem_limit: 128m
|
||||||
# mem_reservation: 64m
|
# mem_reservation: 64m
|
||||||
|
|||||||
Reference in New Issue
Block a user