Skip to content

Commit

Permalink
client_authenticated fix + type export
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Nov 29, 2023
1 parent fdd609f commit 1ba4613
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `bonsaidb::client::Error::Core`'s `Display` no longer just prints "unexpected
disconnection". Instead, the inner error's `Display` is now displayed.
- `bonsaidb::client::Async`/`Blocking` are now exposed. These types are used
when building a client.
- `bonsaidb::server::Backend::client_authenticated` is now invoked.

## v0.5.0

Expand Down
5 changes: 5 additions & 0 deletions crates/bonsaidb-client/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ use crate::client::{AnyApiCallback, ApiCallback};
use crate::BlockingClient;
use crate::{AsyncClient, Error};

/// A type marker for [`Builder`] indicating the returned client should be an
/// [`AsyncClient`].
pub struct Async;

/// A type marker for [`Builder`] indicating the returned client should be an
/// [`BlockingClient`].
#[cfg(not(target_arch = "wasm32"))]
pub struct Blocking;

Expand Down
4 changes: 3 additions & 1 deletion crates/bonsaidb-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ mod error;
#[cfg(not(target_arch = "wasm32"))]
pub use fabruic;

pub use self::builder::Builder;
#[cfg(not(target_arch = "wasm32"))]
pub use self::builder::Blocking;
pub use self::builder::{Async, Builder};
pub use self::client::{ApiCallback, AsyncClient, AsyncRemoteDatabase, AsyncRemoteSubscriber};
#[cfg(not(target_arch = "wasm32"))]
pub use self::client::{BlockingClient, BlockingRemoteDatabase, BlockingRemoteSubscriber};
Expand Down
18 changes: 18 additions & 0 deletions crates/bonsaidb-server/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ impl<B: Backend> Handler<Authenticate, B> for ServerDispatcher {

session.client.logged_in_as(new_session.clone());

if let Err(err) = session
.server
.backend()
.client_authenticated(session.client.clone(), &new_session, session.server)
.await
{
log::error!("[server] Error in `client_authenticated`: {err:?}");
}

Ok(new_session)
}
}
Expand All @@ -215,6 +224,15 @@ impl<B: Backend> Handler<AssumeIdentity, B> for ServerDispatcher {

session.client.logged_in_as(new_session.clone());

if let Err(err) = session
.server
.backend()
.client_authenticated(session.client.clone(), &new_session, session.server)
.await
{
log::error!("[server] Error in `client_authenticated`: {err:?}");
}

Ok(new_session)
}
}
Expand Down

0 comments on commit 1ba4613

Please sign in to comment.