Compare commits

..

1 Commits

Author SHA1 Message Date
YinMo19 96ba2d5d74 Fix compile error. 4 months ago
  1. 3
      CHANGELOG.md
  2. 6
      Cargo.toml
  3. 11
      src/lib.rs

@ -1,6 +1,3 @@
# [0.4.0]
- Update to rocket `0.5.1` and rand `0.9`
# [0.3.0] # [0.3.0]
- Update dependencies - Update dependencies

@ -1,6 +1,6 @@
[package] [package]
name = "rocket_session" name = "rocket_session"
version = "0.4.0" version = "0.3.0"
authors = ["Ondřej Hruška <ondra@ondrovo.com>"] authors = ["Ondřej Hruška <ondra@ondrovo.com>"]
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
@ -16,6 +16,6 @@ categories = [
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
rand = "0.9" rand = "0.8"
rocket = "0.5" rocket = "0.5.0-rc.2"
parking_lot = "0.12" parking_lot = "0.12"

@ -6,7 +6,7 @@ use std::ops::Add;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard}; use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard};
use rand::{rngs::OsRng, Rng, TryRngCore}; use rand::{rngs::OsRng, Rng};
use rocket::{ use rocket::{
fairing::{self, Fairing, Info}, fairing::{self, Fairing, Info},
http::{Cookie, Status}, http::{Cookie, Status},
@ -126,9 +126,7 @@ where
{ {
type Error = (); type Error = ();
async fn from_request( async fn from_request(request: &'r Request<'_>) -> Outcome<Self, (Status, Self::Error), Status> {
request: &'r Request<'_>,
) -> Outcome<Self, (Status, Self::Error), Status> {
let store = request.guard::<&State<SessionStore<D>>>().await.unwrap(); let store = request.guard::<&State<SessionStore<D>>>().await.unwrap();
Outcome::Success(Session { Outcome::Success(Session {
id: request.local_cache(|| { id: request.local_cache(|| {
@ -179,8 +177,7 @@ where
// Find a new unique ID - we are still safely inside the write guard // Find a new unique ID - we are still safely inside the write guard
let new_id = SessionID(loop { let new_id = SessionID(loop {
let token: String = OsRng let token: String = OsRng
.unwrap_err() .sample_iter(&rand::distributions::Alphanumeric)
.sample_iter(&rand::distr::Alphanumeric)
.take(store.config.cookie_len) .take(store.config.cookie_len)
.map(char::from) .map(char::from)
.collect(); .collect();
@ -326,7 +323,7 @@ where
response.adjoin_header( response.adjoin_header(
Cookie::build((self.config.cookie_name.clone(), session.to_string())) Cookie::build((self.config.cookie_name.clone(), session.to_string()))
.path("/") .path("/")
.build(), .finish(),
); );
} }
} }

Loading…
Cancel
Save