Skip to content

Commit

Permalink
remove sending mail when rejected
Browse files Browse the repository at this point in the history
  • Loading branch information
xerbalind committed Oct 2, 2024
1 parent e126f9c commit 22818e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 33 deletions.
16 changes: 0 additions & 16 deletions src/controllers/users_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ pub async fn set_approved<'r>(
pub async fn reject<'r>(
username: String,
_session: AdminSession,
mailer: &'r State<Mailer>,
conf: &'r State<Config>,
db: DbConn,
) -> Result<impl Responder<'r, 'static>> {
let user = User::find_by_username(username, &db).await?;
Expand All @@ -319,20 +317,6 @@ pub async fn reject<'r>(
)));
}

mailer
.create(
&user,
String::from("[Zauth] Your account has been rejected"),
template!(
"mails/user_rejected.txt";
name: String = user.full_name.to_string(),
admin_email: String = conf.admin_email.clone()
)
.render()
.map_err(InternalError::from)?,
)
.await?;

user.delete(&db).await?;

Ok(Accepter {
Expand Down
7 changes: 0 additions & 7 deletions templates/mails/user_rejected.txt

This file was deleted.

17 changes: 7 additions & 10 deletions tests/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,17 +844,14 @@ async fn user_rejectal_flow() {
"after email is confirmed, user should be pending for approval"
);

common::expect_mail_to(vec![&email], async || {
let response = http_client
.post(format!("/users/{}/reject/", user.username))
.header(Accept::HTML)
.header(ContentType::Form)
.dispatch()
.await;
let response = http_client
.post(format!("/users/{}/reject/", user.username))
.header(Accept::HTML)
.header(ContentType::Form)
.dispatch()
.await;

assert_eq!(response.status(), Status::SeeOther);
})
.await;
assert_eq!(response.status(), Status::SeeOther);

user.reload(&db).await.expect_err("user should be removed");
})
Expand Down

0 comments on commit 22818e6

Please sign in to comment.