Skip to content

Commit

Permalink
made invites one time use only
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelCoding committed Mar 23, 2024
1 parent 12bf3c2 commit ef6fbfa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ruth/src/service/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl UserService {
password: &[u8],
) -> anyhow::Result<user::Model> {
let invite = Invite::find_by_id(invite_id)
.filter(invite::Column::Expire.gte(OffsetDateTime::now_utc()))
.one(&self.db)
.await?
// TODO: handle error 410 gone?
Expand Down Expand Up @@ -82,6 +83,11 @@ impl UserService {

password.insert(&self.db).await?;

let result = Invite::delete_by_id(invite_id).exec(&self.db).await?;

// TODO: do we want asserts?
assert_eq!(result.rows_affected, 1);

// TODO: send email verify email

Ok(user)
Expand Down

0 comments on commit ef6fbfa

Please sign in to comment.