Skip to main content

alibi_plugins/user_management/
types.rs

1use serde::{Deserialize, Serialize};
2use validator::Validate;
3
4/// Body of the public `changeEmail` server operation.
5#[derive(Debug, Clone, Serialize, Deserialize, Validate)]
6pub struct ChangeEmailRequest {
7    #[serde(rename = "newEmail")]
8    #[validate(email(message = "Invalid email address"))]
9    pub new_email: String,
10    #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")]
11    pub callback_url: Option<String>,
12}
13
14impl crate::authentication_helpers::RequestBody for ChangeEmailRequest {
15    const FIELDS: &'static [crate::authentication_helpers::JsonField] = &[
16        crate::authentication_helpers::JsonField {
17            name: "newEmail",
18            kind: crate::authentication_helpers::JsonFieldKind::Email,
19            required: true,
20        },
21        crate::authentication_helpers::JsonField::string("callbackURL", false),
22    ];
23}
24
25/// Body of the public `deleteUser` server operation.
26#[derive(Debug, Clone, Default, Serialize, Deserialize, Validate)]
27pub struct DeleteUserRequest {
28    #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")]
29    pub callback_url: Option<String>,
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub password: Option<String>,
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub token: Option<String>,
34}
35
36impl crate::authentication_helpers::RequestBody for DeleteUserRequest {
37    const FIELDS: &'static [crate::authentication_helpers::JsonField] = &[
38        crate::authentication_helpers::JsonField::string("callbackURL", false),
39        crate::authentication_helpers::JsonField::string("password", false),
40        crate::authentication_helpers::JsonField::string("token", false),
41    ];
42}
43
44/// Query of the public `deleteUserCallback` server operation.
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct DeleteUserCallbackQuery {
47    pub token: String,
48    #[serde(rename = "callbackURL", skip_serializing_if = "Option::is_none")]
49    pub callback_url: Option<String>,
50}
51
52impl crate::authentication_helpers::RequestBody for DeleteUserCallbackQuery {
53    const FIELDS: &'static [crate::authentication_helpers::JsonField] = &[
54        crate::authentication_helpers::JsonField::string("token", true),
55        crate::authentication_helpers::JsonField::string("callbackURL", false),
56    ];
57}