Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(admin): reload store before bind validation, filter expired codes, block unauth Feishu channels

cyh8be7ebdb7952
diff --git a/config/v2_settings.py b/config/v2_settings.py
index 7e05f274f..193df6c54 100644
--- a/config/v2_settings.py
+++ b/config/v2_settings.py
@@ -293,6 +293,10 @@ class SettingsStore:
Thread-safe: uses a lock to prevent concurrent bind races.
"""
with self._bind_lock:
+ # Reload from disk so we pick up bind codes created by the UI API
+ # (which uses a separate SettingsStore instance).
+ self._load()
+
# Check already bound
if self.is_bound_user(user_id):
return False, False
diff --git a/modules/im/feishu.py b/modules/im/feishu.py
index 25ccdc82a..804d963e7 100644
--- a/modules/im/feishu.py
+++ b/modules/im/feishu.py
@@ -1230,13 +1230,10 @@ class FeishuBot(BaseIMClient):
is_dm = True
if not is_bound_user or not is_dm:
if not chat_id or not await self._is_authorized_channel(chat_id):
- if is_bound_user:
- # Bound user in a non-authorized channel — allow through
- # but don't mark as DM (it's a channel context)
- pass
- else:
- logger.info("Card action from unauthorized/unknown channel %s, ignoring", chat_id)
- return
+ logger.info(
+ "Card action from unauthorized/unknown channel %s (bound=%s), ignoring", chat_id, is_bound_user
+ )
+ return
context = MessageContext(
user_id=user_id,
diff --git a/vibe/api.py b/vibe/api.py
index 3de0066e8..d5e6f8a2d 100644
--- a/vibe/api.py
+++ b/vibe/api.py
@@ -1223,9 +1223,9 @@ def delete_bind_code(code: str) -> dict:
def get_first_bind_code() -> dict:
"""Get or create the initial bind code for setup wizard."""
store = SettingsStore()
- # If any active code exists, return it
+ # If any valid (active + not expired) code exists, return it
for bc in store.get_bind_codes():
- if bc.is_active:
+ if bc.is_active and store.validate_bind_code(bc.code) is not None:
return {"ok": True, "code": bc.code, "is_new": False}
# Otherwise create a new one-time code
bc = store.create_bind_code("one_time")