Execute SQLs for email_signups in transaction
This commit is contained in:
parent
b6d38536e3
commit
1e3851ea69
@ -90,15 +90,18 @@ impl EmailSignup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn confirm(&self, conn: &DbConn) -> Result<()> {
|
pub fn confirm(&self, conn: &DbConn) -> Result<()> {
|
||||||
|
conn.transaction(|| {
|
||||||
Self::ensure_user_not_exist_by_email(conn, &self.email)?;
|
Self::ensure_user_not_exist_by_email(conn, &self.email)?;
|
||||||
if self.expired() {
|
if self.expired() {
|
||||||
Self::delete_existings_by_email(conn, &self.email)?;
|
Self::delete_existings_by_email(conn, &self.email)?;
|
||||||
return Err(Error::Expired);
|
return Err(Error::Expired);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn complete(&self, conn: &DbConn, username: String, password: String) -> Result<User> {
|
pub fn complete(&self, conn: &DbConn, username: String, password: String) -> Result<User> {
|
||||||
|
conn.transaction(|| {
|
||||||
Self::ensure_user_not_exist_by_email(conn, &self.email)?;
|
Self::ensure_user_not_exist_by_email(conn, &self.email)?;
|
||||||
let user = NewUser::new_local(
|
let user = NewUser::new_local(
|
||||||
conn,
|
conn,
|
||||||
@ -111,6 +114,7 @@ impl EmailSignup {
|
|||||||
)?;
|
)?;
|
||||||
self.delete(conn)?;
|
self.delete(conn)?;
|
||||||
Ok(user)
|
Ok(user)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete(&self, conn: &DbConn) -> Result<()> {
|
fn delete(&self, conn: &DbConn) -> Result<()> {
|
||||||
|
Loading…
Reference in New Issue
Block a user