summaryrefslogtreecommitdiff
path: root/server/src/models
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-08-22 17:33:47 +0200
committerSanto Cariotti <santo@dcariotti.me>2022-08-22 17:33:47 +0200
commitaff24b4ce5be0172e34e02e06e7b5fa43026c4bf (patch)
treede0067a34aa9c6d8ed30ced28a436ed989dc2e9b /server/src/models
parent9487da48222c846533ecac4bc115d40dab35b9cc (diff)
Hide password on users list
Diffstat (limited to 'server/src/models')
-rw-r--r--server/src/models/user.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/server/src/models/user.rs b/server/src/models/user.rs
index 72fd56a..08514a8 100644
--- a/server/src/models/user.rs
+++ b/server/src/models/user.rs
@@ -10,6 +10,12 @@ pub struct User {
password: String,
}
+#[derive(Deserialize, Serialize)]
+pub struct UserList {
+ id: i32,
+ email: String,
+}
+
impl User {
pub async fn create(user: User) -> Result<i32, AppError> {
let pool = unsafe { get_client() };
@@ -28,9 +34,9 @@ impl User {
Ok(rec.id)
}
- pub async fn list() -> Result<Vec<User>, AppError> {
+ pub async fn list() -> Result<Vec<UserList>, AppError> {
let pool = unsafe { get_client() };
- let rows = sqlx::query_as!(User, r#"SELECT id, email, password FROM users"#)
+ let rows = sqlx::query_as!(UserList, r#"SELECT id, email FROM users"#)
.fetch_all(pool)
.await?;