This repository has been archived on 2026-09-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tauri-plugin-auth/src/lib.rs
T
rizky_denianto caf005b82d
Penerbitan Plugin / persiapan (pull_request) Successful in 5s
Penerbitan Plugin / penerbitan (pull_request) Failing after 1m29s
Menyelesaikan plugin, siap ucob
2026-09-02 23:13:23 +07:00

49 lines
1.0 KiB
Rust

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;
use crate::commands::{keluar, masuk};
/// 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![masuk, keluar])
.setup(|app, api| {
#[cfg(mobile)]
let auth = mobile::init(app, api)?;
#[cfg(desktop)]
let auth = desktop::init(app, api)?;
app.manage(auth);
Ok(())
})
.build()
}