Skip to content

Commit af4c991

Browse files
committed
backend/register: dont leak used emai-addresses.
1 parent 764b570 commit af4c991

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

backend/src/routes/auth/register.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use validator::Validate;
3434
use crate::{
3535
error::Error,
3636
routes::auth::VERIFICATION_EXPIRATION_DAYS,
37-
utils::{self, get_connection, web_block_unpacked},
37+
utils::{self, get_connection},
3838
AppState,
3939
};
4040

@@ -138,7 +138,7 @@ pub async fn register(
138138
let user_mail = data.email.to_lowercase();
139139
let mail_cpy = user_mail.clone();
140140

141-
web_block_unpacked(move || {
141+
match web::block(move || {
142142
use db_connector::schema::users::dsl::*;
143143

144144
match users
@@ -153,7 +153,12 @@ pub async fn register(
153153

154154
Ok(())
155155
})
156-
.await?;
156+
.await {
157+
Ok(Ok(_)) => (),
158+
Ok(Err(Error::UserAlreadyExists)) => return Ok(HttpResponse::Created()),
159+
Ok(Err(_)) => return Err(Error::InternalError.into()),
160+
Err(_) => return Err(Error::InternalError.into()),
161+
}
157162

158163
let key_hash = match hash_key(&data.login_key) {
159164
Ok(hash) => hash,

0 commit comments

Comments
 (0)