-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Reject button for new registrations (#295)
* Add reject functionality * Update templates/mails/user_rejected.txt Co-authored-by: Rien <[email protected]> * remove sending mail when rejected --------- Co-authored-by: Rien <[email protected]>
- Loading branch information
Showing
4 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -788,6 +788,76 @@ async fn user_approval_flow() { | |
.await; | ||
} | ||
|
||
#[rocket::async_test] | ||
async fn user_rejectal_flow() { | ||
common::as_admin(async move |http_client: HttpClient, db, _admin| { | ||
let email = String::from("[email protected]"); | ||
let user = User::create_pending( | ||
NewUser { | ||
username: String::from("user"), | ||
password: String::from("password"), | ||
full_name: String::from("name"), | ||
email: email.clone(), | ||
ssh_key: None, | ||
not_a_robot: true, | ||
}, | ||
&common::config(), | ||
&db, | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
let token = user | ||
.pending_email_token | ||
.as_ref() | ||
.expect("email token") | ||
.clone(); | ||
|
||
let response = http_client | ||
.get(format!("/users/confirm/{}", token)) | ||
.header(Accept::HTML) | ||
.header(ContentType::Form) | ||
.dispatch() | ||
.await; | ||
|
||
assert_eq!(response.status(), Status::Ok); | ||
|
||
let response = | ||
common::expect_mail_to(vec!["admin@localhost"], async || { | ||
http_client | ||
.post("/users/confirm") | ||
.header(Accept::HTML) | ||
.header(ContentType::Form) | ||
.body(format!("token={}", token)) | ||
.dispatch() | ||
.await | ||
}) | ||
.await; | ||
|
||
assert_eq!(response.status(), Status::Ok); | ||
|
||
let user = user.reload(&db).await.expect("reload user"); | ||
|
||
assert_eq!( | ||
user.state, | ||
UserState::PendingApproval, | ||
"after email is confirmed, user should be pending for approval" | ||
); | ||
|
||
let response = http_client | ||
.post(format!("/users/{}/reject/", user.username)) | ||
.header(Accept::HTML) | ||
.header(ContentType::Form) | ||
.dispatch() | ||
.await; | ||
|
||
assert_eq!(response.status(), Status::SeeOther); | ||
|
||
user.reload(&db).await.expect_err("user should be removed"); | ||
}) | ||
.await; | ||
} | ||
|
||
#[rocket::async_test] | ||
async fn refuse_robots() { | ||
common::as_visitor(async move |http_client: HttpClient, db| { | ||
|