summaryrefslogtreecommitdiffstats
path: root/src/api/users.rs
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-04-16 20:28:46 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-04-16 20:28:46 -0500
commita2860a1294b250402114fa016c4639881abc2172 (patch)
tree96609af1fe197ec0186f0f409ccfbb8b1012951d /src/api/users.rs
parent917293785bffdd64d467e7d69b5645099b21d5e9 (diff)
refactor: improve account extractors
Diffstat (limited to 'src/api/users.rs')
-rw-r--r--src/api/users.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/api/users.rs b/src/api/users.rs
index c8a390d..6ac0bb8 100644
--- a/src/api/users.rs
+++ b/src/api/users.rs
@@ -11,7 +11,10 @@ use sqlx::FromRow;
use time::OffsetDateTime;
use uuid::Uuid;
-use crate::{auth::AccessClaims, state::AppState};
+use crate::{
+ auth::{credentials::Credential, AccessClaims},
+ state::AppState,
+};
use super::error::Error;
@@ -30,7 +33,7 @@ pub struct User {
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
-pub struct RegisterSchema {
+pub struct Registration {
pub name: String,
pub email: String,
pub password: String,
@@ -38,11 +41,11 @@ pub struct RegisterSchema {
pub async fn create(
State(state): State<AppState>,
- Json(RegisterSchema {
+ Json(Registration {
name,
email,
password,
- }): Json<RegisterSchema>,
+ }): Json<Registration>,
) -> impl IntoResponse {
email_address::EmailAddress::from_str(&email)?;
@@ -58,11 +61,9 @@ pub async fn create(
}
// TODO: Move this into a micro service, possibly behind a feature flag.
- let (status, (access, refresh)) = crate::auth::credentials::create(
- State(state.clone()),
- Json(crate::auth::credentials::Credential { password }),
- )
- .await?;
+ let (status, (access, refresh)) =
+ crate::auth::credentials::create(State(state.clone()), Json(Credential { password }))
+ .await?;
let user = sqlx::query_as!(
User,