Skip to content

Commit 4e9bb2a

Browse files
feat(workos): add WorkOS method (#161)
1 parent f796fce commit 4e9bb2a

36 files changed

Lines changed: 757 additions & 64 deletions

File tree

Cargo.lock

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ bon = "3.3.2"
2121
chrono = "0.4.39"
2222
console_error_panic_hook = "0.1.2"
2323
dioxus = "0.7.0-rc.0"
24-
dioxus-server = { version = "0.7.0-rc.0" }
24+
dioxus-html = "0.7.0-rc.0"
25+
dioxus-server = "0.7.0-rc.0"
2526
futures = "0.3.31"
2627
http = "1.2.0"
2728
leptos = "0.8.3"
@@ -53,6 +54,7 @@ shield-sea-orm = { path = "./packages/storage/shield-sea-orm", version = "0.0.4"
5354
shield-sqlx = { path = "./packages/storage/shield-sqlx", version = "0.0.4" }
5455
shield-tower = { path = "./packages/integrations/shield-tower", version = "0.0.4" }
5556
shield-webauthn = { path = "./packages/methods/shield-webauthn", version = "0.0.4" }
57+
shield-workos = { path = "./packages/methods/shield-workos", version = "0.0.4" }
5658
thiserror = "2.0.7"
5759
tokio = "1.42.0"
5860
tower-layer = "0.3.3"

packages/core/shield/src/action.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@ use crate::{
1313
pub struct ActionForms {
1414
pub id: String,
1515
pub name: String,
16-
pub forms: Vec<ActionProviderForm>,
16+
pub method_forms: Vec<ActionMethodForm>,
17+
}
18+
19+
// TODO: Think of a better name.
20+
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
21+
pub struct ActionMethodForm {
22+
pub id: String,
23+
pub provider_forms: Vec<ActionProviderForm>,
1724
}
1825

1926
// TODO: Think of a better name.
2027
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
2128
pub struct ActionProviderForm {
22-
pub method_id: String,
23-
pub provider_id: Option<String>,
29+
pub id: Option<String>,
2430
pub form: Form,
2531
}
2632

@@ -34,7 +40,7 @@ pub trait Action<P: Provider>: ErasedAction + Send + Sync {
3440
Ok(true)
3541
}
3642

37-
fn form(&self, provider: P) -> Form;
43+
fn forms(&self, provider: P) -> Vec<Form>;
3844

3945
async fn call(
4046
&self,
@@ -56,7 +62,7 @@ pub trait ErasedAction: Send + Sync {
5662
session: Session,
5763
) -> Result<bool, ShieldError>;
5864

59-
fn erased_form(&self, provider: Box<dyn Any + Send + Sync>) -> Form;
65+
fn erased_forms(&self, provider: Box<dyn Any + Send + Sync>) -> Vec<Form>;
6066

6167
async fn erased_call(
6268
&self,
@@ -83,8 +89,8 @@ macro_rules! erased_action {
8389
self.condition(provider.downcast_ref().expect("TODO"), session)
8490
}
8591

86-
fn erased_form(&self, provider: Box<dyn std::any::Any + Send + Sync>) -> $crate::Form {
87-
self.form(*provider.downcast().expect("TODO"))
92+
fn erased_forms(&self, provider: Box<dyn std::any::Any + Send + Sync>) -> Vec<$crate::Form> {
93+
self.forms(*provider.downcast().expect("TODO"))
8894
}
8995

9096
async fn erased_call(
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
mod sign_in;
22
mod sign_in_callback;
33
mod sign_out;
4+
mod sign_up;
45

56
pub use sign_in::*;
67
pub use sign_in_callback::*;
78
pub use sign_out::*;
9+
pub use sign_up::*;

packages/core/shield/src/actions/sign_out.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ impl SignOutAction {
3131
}))
3232
}
3333

34-
pub fn form<P: Provider>(_provider: P) -> Form {
35-
Form {
34+
pub fn forms<P: Provider>(_provider: P) -> Vec<Form> {
35+
vec![Form {
3636
inputs: vec![Input {
3737
name: "submit".to_owned(),
3838
label: None,
3939
r#type: InputType::Submit(InputTypeSubmit {}),
4040
value: Some(Self::name()),
4141
}],
42-
}
42+
}]
4343
}
4444
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const ACTION_ID: &str = "sign-up";
2+
const ACTION_NAME: &str = "Sign up";
3+
4+
pub struct SignUpAction;
5+
6+
impl SignUpAction {
7+
pub fn id() -> String {
8+
ACTION_ID.to_owned()
9+
}
10+
11+
pub fn name() -> String {
12+
ACTION_NAME.to_owned()
13+
}
14+
}

0 commit comments

Comments
 (0)