fix: update updated_at when reset user auth token (#1006)

r0.7
Meng Zhang 2023-12-10 15:18:24 +08:00 committed by GitHub
parent 58787e707b
commit 766c481c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -143,7 +143,7 @@ impl DbConn {
pub async fn reset_registration_token(&self) -> Result<String> {
let token = uuid::Uuid::new_v4().to_string();
let result = token.clone();
let updated_at = chrono::Utc::now().timestamp() as u32;
let updated_at = chrono::Utc::now();
let res = self
.conn

View File

@ -178,10 +178,13 @@ impl DbConn {
pub async fn reset_user_auth_token_by_email(&self, email: &str) -> Result<()> {
let email = email.to_owned();
let updated_at = chrono::Utc::now();
self.conn
.call(move |c| {
let mut stmt = c.prepare(r#"UPDATE users SET auth_token = ? WHERE email = ?"#)?;
stmt.execute((generate_auth_token(), email))?;
let mut stmt = c.prepare(
r#"UPDATE users SET auth_token = ?, updated_at = ? WHERE email = ?"#,
)?;
stmt.execute((generate_auth_token(), updated_at, email))?;
Ok(())
})
.await?;