Skip to content

Commit

Permalink
Stop rolling device token
Browse files Browse the repository at this point in the history
  • Loading branch information
Timshel committed Jul 22, 2024
1 parent fa05a38 commit a20d428
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
3 changes: 1 addition & 2 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,8 +1098,7 @@ pub async fn refresh_tokens(refresh_token: &str, conn: &mut DbConn) -> ApiResult
Some(device) => device,
};

// Roll the Device.refresh_token this way it invalides old JWT refresh_token
device.roll_refresh_token();
// Save to update `updated_at`.
device.save(conn).await?;

let user = match User::find_by_uuid(&device.user_uuid, conn).await {
Expand Down
4 changes: 0 additions & 4 deletions src/db/models/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ impl Device {
}
}

pub fn roll_refresh_token(&mut self) {
self.refresh_token = crypto::encode_random_bytes::<64>(BASE64URL)
}

pub fn refresh_twofactor_remember(&mut self) -> String {
let twofactor_remember = crypto::encode_random_bytes::<180>(BASE64);
self.twofactor_remember = Some(twofactor_remember.clone());
Expand Down

0 comments on commit a20d428

Please sign in to comment.