Skip to content

Commit be65713

Browse files
committed
Include whether the user email is verified rather than not including unverified emails
1 parent b22def0 commit be65713

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/controllers/admin.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub async fn list(
3030
));
3131
}
3232

33-
let (user, verified, email) = users::table
33+
let (user, verified, user_email) = users::table
3434
.left_join(emails::table)
3535
.filter(users::gh_login.eq(username))
3636
.select((
@@ -79,7 +79,6 @@ pub async fn list(
7979
.load(&mut conn)
8080
.await?;
8181

82-
let verified = verified.unwrap_or(false);
8382
let crates = crates
8483
.into_iter()
8584
.map(
@@ -113,14 +112,16 @@ pub async fn list(
113112
)
114113
.collect();
115114
Ok(Json(AdminListResponse {
116-
user_email: verified.then_some(email).flatten(),
115+
user_email,
116+
user_email_verified: verified.unwrap_or_default(),
117117
crates,
118118
}))
119119
}
120120

121121
#[derive(Debug, Serialize)]
122122
pub struct AdminListResponse {
123123
user_email: Option<String>,
124+
user_email_verified: bool,
124125
crates: Vec<AdminCrateInfo>,
125126
}
126127

src/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ pub struct OkBool {
8787
#[derive(Deserialize, Debug)]
8888
pub struct AdminListResponse {
8989
user_email: Option<String>,
90+
user_email_verified: bool,
9091
crates: Vec<AdminCrateInfo>,
9192
}
9293
#[derive(Deserialize, Debug)]

src/tests/routes/crates/admin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ async fn index_include_yanked() -> anyhow::Result<()> {
6868
let json = admin.admin_list(username).await.good();
6969

7070
assert_eq!(json.user_email.unwrap(), "foo@example.com");
71+
assert!(json.user_email_verified);
7172
assert_eq!(json.crates.len(), 2);
7273

7374
let json_crate_0 = &json.crates[0];

0 commit comments

Comments
 (0)