Skip to content

Commit ec1b066

Browse files
committed
database/models/email: Implement Selectable trait
1 parent fd1856a commit ec1b066

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

crates/crates_io_database/src/models/email.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use bon::Builder;
2-
use chrono::{DateTime, Utc};
32
use diesel::prelude::*;
43
use diesel_async::{AsyncPgConnection, RunQueryDsl};
54
use secrecy::SecretString;
65

76
use crate::models::User;
87
use crate::schema::emails;
98

10-
#[derive(Debug, Queryable, Identifiable, Associations)]
9+
#[derive(Debug, Queryable, Identifiable, Selectable, Associations)]
1110
#[diesel(belongs_to(User))]
1211
pub struct Email {
1312
pub id: i32,
@@ -16,7 +15,6 @@ pub struct Email {
1615
pub verified: bool,
1716
#[diesel(deserialize_as = String, serialize_as = String)]
1817
pub token: SecretString,
19-
pub token_generated_at: Option<DateTime<Utc>>,
2018
}
2119

2220
#[derive(Debug, Insertable, AsChangeset, Builder)]

src/controllers/user/email_verification.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub async fn resend_email_verification(
7474
async move {
7575
let email: Email = diesel::update(Email::belonging_to(auth.user()))
7676
.set(emails::token.eq(sql("DEFAULT")))
77+
.returning(Email::as_returning())
7778
.get_result(conn)
7879
.await
7980
.optional()?

0 commit comments

Comments
 (0)