Skip to content

Commit

Permalink
Add account 2FA endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
novacrazy committed Aug 12, 2023
1 parent e14f589 commit 19634a6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/api/commands/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,37 @@ command! {
}
}

+struct Enable2FA -> Added2FA: POST[2000 ms, 1]("user" / "@me" / "2fa") {
;
#[cfg_attr(feature = "builder", derive(typed_builder::TypedBuilder))]
struct Enable2FAForm {
#[cfg_attr(feature = "builder", builder(setter(into)))]
pub password: SmolStr,
#[cfg_attr(feature = "builder", builder(setter(into)))]
pub token: String,
}
}

+struct Confirm2FA -> (): PATCH[2000 ms, 1]("user" / "@me" / "2fa") {
;
#[cfg_attr(feature = "builder", derive(typed_builder::TypedBuilder))]
struct Confirm2FAForm {
#[cfg_attr(feature = "builder", builder(setter(into)))]
pub totp: SmolStr,
}
}

+struct Remove2FA -> (): DELETE[2000 ms, 1]("user" / "@me" / "2fa") {
;
#[cfg_attr(feature = "builder", derive(typed_builder::TypedBuilder))]
struct Remove2FAForm {
#[cfg_attr(feature = "builder", builder(setter(into)))]
pub password: SmolStr,
#[cfg_attr(feature = "builder", builder(setter(into)))]
pub totp: SmolStr,
}
}

+struct GetSessions -> Vec<AnonymousSession>: GET[500 ms, 1]("user" / "@me" / "sessions") {}

/// Clears all **other** sessions
Expand Down Expand Up @@ -112,3 +143,8 @@ impl From<UserPreferences> for UpdateUserPrefsBody {
UpdateUserPrefsBody { inner }
}
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct Added2FA {
pub url: String,
pub backup: Vec<String>,
}

0 comments on commit 19634a6

Please sign in to comment.