You've already forked AstralRinth
forked from didirus/AstralRinth
Monorepo missing features (#1273)
* fix tauri config * fix package patch * regen pnpm lock * use new workflow * New GH actions * Update lockfile * update scripts * Fix build script * Fix missing deps * Fix assets eslint * Update libraries lint * Fix all lint configs * update lockfile * add fmt + clippy fails * Separate App Tauri portion * fix app features * Fix lints * install tauri cli * update lockfile * corepack, fix lints * add store path * fix unused import * Fix tests * Issue templates + port over tauri release * fix actions * fix before build command * Add X86 target * Update build matrix * finalize actions * make debug build smaller * Use debug build to make cache smaller * dummy commit * change proj name * update file name * Use release builds for less space use * Remove rust cache * Readd for app build * add merge queue trigger
This commit is contained in:
82
apps/app/src/api/mr_auth.rs
Normal file
82
apps/app/src/api/mr_auth.rs
Normal file
@@ -0,0 +1,82 @@
|
||||
use crate::api::Result;
|
||||
use tauri::plugin::TauriPlugin;
|
||||
use theseus::prelude::*;
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("mr_auth")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
authenticate_begin_flow,
|
||||
authenticate_await_completion,
|
||||
cancel_flow,
|
||||
login_pass,
|
||||
login_2fa,
|
||||
create_account,
|
||||
refresh,
|
||||
logout,
|
||||
get,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn authenticate_begin_flow(provider: &str) -> Result<String> {
|
||||
Ok(theseus::mr_auth::authenticate_begin_flow(provider).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn authenticate_await_completion() -> Result<ModrinthCredentialsResult>
|
||||
{
|
||||
Ok(theseus::mr_auth::authenticate_await_complete_flow().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn cancel_flow() -> Result<()> {
|
||||
Ok(theseus::mr_auth::cancel_flow().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn login_pass(
|
||||
username: &str,
|
||||
password: &str,
|
||||
challenge: &str,
|
||||
) -> Result<ModrinthCredentialsResult> {
|
||||
Ok(theseus::mr_auth::login_password(username, password, challenge).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn login_2fa(code: &str, flow: &str) -> Result<ModrinthCredentials> {
|
||||
Ok(theseus::mr_auth::login_2fa(code, flow).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn create_account(
|
||||
username: &str,
|
||||
email: &str,
|
||||
password: &str,
|
||||
challenge: &str,
|
||||
sign_up_newsletter: bool,
|
||||
) -> Result<ModrinthCredentials> {
|
||||
Ok(theseus::mr_auth::create_account(
|
||||
username,
|
||||
email,
|
||||
password,
|
||||
challenge,
|
||||
sign_up_newsletter,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn refresh() -> Result<()> {
|
||||
Ok(theseus::mr_auth::refresh().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn logout() -> Result<()> {
|
||||
Ok(theseus::mr_auth::logout().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get() -> Result<Option<ModrinthCredentials>> {
|
||||
Ok(theseus::mr_auth::get_credentials().await?)
|
||||
}
|
||||
Reference in New Issue
Block a user