Unggahan awal

This commit is contained in:
rizky_denianto committed 2026-09-01 23:19:26 +07:00
1 parent 7915065d1c
commit 8c96423e9b
19 files changed
+686

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
use tauri::{
Manager, Runtime,
plugin::{Builder, TauriPlugin},
};
#[cfg(desktop)]
mod desktop;
#[cfg(mobile)]
mod mobile;
mod commands;
mod error;
mod models;
pub use error::{Error, Result};
#[cfg(desktop)]
use desktop::Auth;
#[cfg(mobile)]
use mobile::Auth;
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the auth APIs.
pub trait AuthExt<R: Runtime> {
fn auth(&self) -> &Auth<R>;
}
impl<R: Runtime, T: Manager<R>> crate::AuthExt<R> for T {
fn auth(&self) -> &Auth<R> {
self.state::<Auth<R>>().inner()
}
}
/// Initializes the plugin.
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("auth")
.invoke_handler(tauri::generate_handler![commands::autentikasi])
.setup(|app, api| {
#[cfg(mobile)]
let auth = mobile::init(app, api)?;
#[cfg(desktop)]
let auth = desktop::init(app, api)?;
app.manage(auth);
Ok(())
})
.build()
}