pub trait FirebaseAuthService<C: ApiHttpClient>:
Send
+ Sync
+ 'static {
// Required methods
fn get_client(&self) -> &C;
fn get_auth_uri_builder(&self) -> &ApiUriBuilder;
// Provided methods
fn create_user(
&self,
user: NewUser,
) -> impl Future<Output = Result<User, Report<ApiClientError>>> + Send { ... }
fn get_user(
&self,
indentifiers: UserIdentifiers,
) -> impl Future<Output = Result<Option<User>, Report<ApiClientError>>> + Send { ... }
fn get_users(
&self,
indentifiers: UserIdentifiers,
) -> impl Future<Output = Result<Option<Vec<User>>, Report<ApiClientError>>> + Send { ... }
fn list_users(
&self,
users_per_page: usize,
prev: Option<UserList>,
) -> impl Future<Output = Result<Option<UserList>, Report<ApiClientError>>> + Send { ... }
fn delete_user(
&self,
uid: String,
) -> impl Future<Output = Result<(), Report<ApiClientError>>> + Send { ... }
fn delete_users(
&self,
uids: Vec<String>,
force: bool,
) -> impl Future<Output = Result<(), Report<ApiClientError>>> + Send { ... }
fn update_user(
&self,
update: UserUpdate,
) -> impl Future<Output = Result<User, Report<ApiClientError>>> + Send { ... }
fn import_users(
&self,
users: Vec<UserImportRecord>,
) -> impl Future<Output = Result<(), Report<ApiClientError>>> + Send { ... }
fn generate_email_action_link(
&self,
oob_action: OobCodeAction,
) -> impl Future<Output = Result<String, Report<ApiClientError>>> + Send { ... }
fn create_session_cookie(
&self,
id_token: String,
expires_in: Duration,
) -> impl Future<Output = Result<String, Report<ApiClientError>>> + Send { ... }
}Required Methods§
fn get_client(&self) -> &C
fn get_auth_uri_builder(&self) -> &ApiUriBuilder
Provided Methods§
Sourcefn create_user(
&self,
user: NewUser,
) -> impl Future<Output = Result<User, Report<ApiClientError>>> + Send
fn create_user( &self, user: NewUser, ) -> impl Future<Output = Result<User, Report<ApiClientError>>> + Send
Creates a new user account with the specified properties.
§Example
let new_user = auth.create_user(
NewUser::email_and_password(
"test@example.com".into(),
"123ABC".into(),
)
).await.unwrap();Sourcefn get_user(
&self,
indentifiers: UserIdentifiers,
) -> impl Future<Output = Result<Option<User>, Report<ApiClientError>>> + Send
fn get_user( &self, indentifiers: UserIdentifiers, ) -> impl Future<Output = Result<Option<User>, Report<ApiClientError>>> + Send
Get first user that matches given identifier filter
§Example
let user = auth.get_user(
UserIdentifiers {
email: Some(vec!["me@example.com".into()]),
..Default::default()
}
).await.unwrap();Sourcefn get_users(
&self,
indentifiers: UserIdentifiers,
) -> impl Future<Output = Result<Option<Vec<User>>, Report<ApiClientError>>> + Send
fn get_users( &self, indentifiers: UserIdentifiers, ) -> impl Future<Output = Result<Option<Vec<User>>, Report<ApiClientError>>> + Send
Get all users that match a given identifier filter
§Example
let users = auth.get_users(
UserIdentifiers {
email: Some(vec!["me@example.com".into()]),
uid: Some(vec!["A123456".into()]),
..Default::default()
}
).await.unwrap().unwrap();Sourcefn list_users(
&self,
users_per_page: usize,
prev: Option<UserList>,
) -> impl Future<Output = Result<Option<UserList>, Report<ApiClientError>>> + Send
fn list_users( &self, users_per_page: usize, prev: Option<UserList>, ) -> impl Future<Output = Result<Option<UserList>, Report<ApiClientError>>> + Send
Fetch all users in batches of users_per_page, to progress pass previous page into the method’s prev.
§Example
let mut user_page: Option<UserList> = None;
loop {
user_page = auth.list_users(10, user_page).await.unwrap();
if let Some(user_page) = &user_page {
for user in &user_page.users {
println!("User: {user:?}");
}
} else {
break;
}
}Sourcefn delete_user(
&self,
uid: String,
) -> impl Future<Output = Result<(), Report<ApiClientError>>> + Send
fn delete_user( &self, uid: String, ) -> impl Future<Output = Result<(), Report<ApiClientError>>> + Send
Delete user with given ID
Sourcefn delete_users(
&self,
uids: Vec<String>,
force: bool,
) -> impl Future<Output = Result<(), Report<ApiClientError>>> + Send
fn delete_users( &self, uids: Vec<String>, force: bool, ) -> impl Future<Output = Result<(), Report<ApiClientError>>> + Send
Delete all users with given list of IDs
Sourcefn update_user(
&self,
update: UserUpdate,
) -> impl Future<Output = Result<User, Report<ApiClientError>>> + Send
fn update_user( &self, update: UserUpdate, ) -> impl Future<Output = Result<User, Report<ApiClientError>>> + Send
Update user with given changes
§Example
let update = UserUpdate::builder("ID123".into())
.display_name(AttributeOp::Change("My new name".into()))
.phone_number(AttributeOp::Delete)
.email("new@example.com".into())
.build();
auth.update_user(update).await.unwrap();Sourcefn import_users(
&self,
users: Vec<UserImportRecord>,
) -> impl Future<Output = Result<(), Report<ApiClientError>>> + Send
fn import_users( &self, users: Vec<UserImportRecord>, ) -> impl Future<Output = Result<(), Report<ApiClientError>>> + Send
Create users in bulk
§Example
let records = vec![
UserImportRecord::builder()
.with_email("me@example.com".into(), true)
.with_display_name("My Name".into())
.build()
];
auth.import_users(records).await.unwrap();Sourcefn generate_email_action_link(
&self,
oob_action: OobCodeAction,
) -> impl Future<Output = Result<String, Report<ApiClientError>>> + Send
fn generate_email_action_link( &self, oob_action: OobCodeAction, ) -> impl Future<Output = Result<String, Report<ApiClientError>>> + Send
Send email with OOB code action
§Example
let oob_action = OobCodeAction::builder(
OobCodeActionType::PasswordReset,
"me@example.com".into()
).build();
let link = auth.generate_email_action_link(oob_action).await.unwrap();Create session cookie
that then can be verified and parsed with App::live().cookie_token_verifier()
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.