feat(core): add set_session to QbzCore and login_with_session to CoreBridge for OAuth

This commit is contained in:
vicrodh committed 2026-02-23 14:45:24 -06:00
1 parent 5ed96c1d2d
commit 9d6be623d4
2 files changed
+22

No files matched your search

+13
View File
@@ -109,6 +109,19 @@ impl<A: FrontendAdapter + Send + Sync + 'static> QbzCore<A> {
}
}
/// Inject an already-authenticated session (e.g. from OAuth flow).
/// Emits a LoggedIn event so the rest of the system knows auth state changed.
pub async fn set_session(&self, session: UserSession) -> Result<(), CoreError> {
let client = self.client.read().await;
let client = client.as_ref().ok_or(CoreError::NotInitialized)?;
client.set_session(session.clone()).await;
self.emit(CoreEvent::LoggedIn {
session,
})
.await;
Ok(())
}
/// Logout the current user
pub async fn logout(&self) -> Result<(), CoreError> {
let client = self.client.read().await;
+9
View File
@@ -94,6 +94,15 @@ impl CoreBridge {
.map_err(|e| e.to_string())
}
/// Inject an already-authenticated session (for OAuth flow where we have
/// the UserSession from the legacy client but not email/password).
pub async fn login_with_session(&self, session: UserSession) -> Result<(), String> {
self.core
.set_session(session)
.await
.map_err(|e| e.to_string())
}
/// Logout current user
pub async fn logout(&self) -> Result<(), String> {
self.core.logout().await.map_err(|e| e.to_string())