Register endpoint #16

Merged
phoenix merged 56 commits from register_endpoint-init into devel 2025-04-05 19:26:59 +00:00
2 changed files with 7 additions and 27 deletions
Showing only changes of commit dc1f417c4f - Show all commits

View File

@@ -235,6 +235,10 @@ mod tests {
usr.username, returned_usr.username,
"Usernames do not match"
);
assert!(
!returned_usr.date_created.is_empty(),
"Date Created is empty"
);
}
Err(err) => {
assert!(false, "Error: {:?}", err.to_string());

View File

@@ -1,12 +1,8 @@
pub mod user {
// use crate::models;
// use serde::Serialize;
#[derive(Debug, serde::Serialize, sqlx::FromRow)]
pub struct InsertedData {
pub id: uuid::Uuid,
pub date_created: Option<time::OffsetDateTime>,
// pub email: String,
}
pub async fn insert(
@@ -16,11 +12,11 @@ pub mod user {
let result = sqlx::query_as!(
InsertedData,
r#"
INSERT INTO "user" (username, password, email, phone, firstname, lastname, email_verified, status, date_created)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, NOW())
INSERT INTO "user" (username, password, email, phone, firstname, lastname, email_verified, status)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
RETURNING id, date_created;
"#,
&user.username, // Bind the input message securely
&user.username,
&user.password,
&user.email,
&user.phone,
@@ -40,25 +36,5 @@ pub mod user {
Ok(id) => Ok(id.id),
Err(err) => Err(err),
}
/*
let insert_sql = "INSERT INTO \"user\" (username, password, email, phone, firstname, lastname, email_verified, status) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id";
match sqlx::query_scalar(insert_sql)
.bind(&user.username) // Bind the input message securely
.bind(&user.password)
.bind(&user.email)
.bind(&user.phone)
.bind(&user.firstname)
.bind(&user.lastname)
.bind(user.email_verified)
.bind(&user.status)
.fetch_one(pool) // Execute and expect exactly ONE row with ONE column back
.await
{
Ok(o) => Ok(o),
Err(err) => Err(err), // _ => uuid::Uuid::nil(),
}
*/
}
}