Merge branch 'new-rocket' into 'staging'

update deps, switch to newest rocket version

See merge request PhilippHofer/rot!86
This commit is contained in:
PhilippHofer 2023-11-08 17:03:25 +00:00
commit ae7391e239
5 changed files with 181 additions and 257 deletions

406
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -9,8 +9,8 @@ rowing-tera = ["rocket_dyn_templates", "tera"]
rest = []
[dependencies]
rocket = { version = "0.5.0-rc.3", features = ["secrets"]}
rocket_dyn_templates = {version = "0.1.0-rc.3", features = [ "tera" ], optional = true }
rocket = { version = "0.5.0-rc.4", features = ["secrets"]}
rocket_dyn_templates = {version = "0.1.0-rc.4", features = [ "tera" ], optional = true }
log = "0.4"
env_logger = "0.10"
sqlx = { version = "0.6", features = ["sqlite", "runtime-tokio-rustls", "macros", "chrono", "time"] }

View File

@ -359,10 +359,10 @@ impl<'r> FromRequest<'r> for User {
Ok(user_id) => {
let db = req.rocket().state::<SqlitePool>().unwrap();
let Some(user) = User::find_by_id(db, user_id).await else {
return Outcome::Failure((Status::Unauthorized, LoginError::UserNotFound));
return Outcome::Error((Status::Unauthorized, LoginError::UserNotFound));
};
if user.deleted {
return Outcome::Failure((Status::Unauthorized, LoginError::UserDeleted));
return Outcome::Error((Status::Unauthorized, LoginError::UserDeleted));
}
user.logged_in(db).await;
@ -374,10 +374,10 @@ impl<'r> FromRequest<'r> for User {
}
Err(_) => {
println!("{:?}", user_id.value());
Outcome::Failure((Status::Unauthorized, LoginError::DeserializationError))
Outcome::Error((Status::Unauthorized, LoginError::DeserializationError))
}
},
None => Outcome::Failure((Status::Unauthorized, LoginError::NotLoggedIn)),
None => Outcome::Error((Status::Unauthorized, LoginError::NotLoggedIn)),
}
}
}
@ -414,9 +414,9 @@ impl<'r> FromRequest<'r> for TechUser {
match User::from_request(req).await {
Outcome::Success(user) => match user.try_into() {
Ok(user) => Outcome::Success(user),
Err(_) => Outcome::Failure((Status::Unauthorized, LoginError::NotACox)),
Err(_) => Outcome::Error((Status::Unauthorized, LoginError::NotACox)),
},
Outcome::Failure(f) => Outcome::Failure(f),
Outcome::Error(f) => Outcome::Error(f),
Outcome::Forward(f) => Outcome::Forward(f),
}
}
@ -454,9 +454,9 @@ impl<'r> FromRequest<'r> for CoxUser {
match User::from_request(req).await {
Outcome::Success(user) => match user.try_into() {
Ok(user) => Outcome::Success(user),
Err(_) => Outcome::Failure((Status::Unauthorized, LoginError::NotACox)),
Err(_) => Outcome::Error((Status::Unauthorized, LoginError::NotACox)),
},
Outcome::Failure(f) => Outcome::Failure(f),
Outcome::Error(f) => Outcome::Error(f),
Outcome::Forward(f) => Outcome::Forward(f),
}
}
@ -487,9 +487,9 @@ impl<'r> FromRequest<'r> for AdminUser {
match User::from_request(req).await {
Outcome::Success(user) => match user.try_into() {
Ok(user) => Outcome::Success(user),
Err(_) => Outcome::Failure((Status::Unauthorized, LoginError::NotAnAdmin)),
Err(_) => Outcome::Error((Status::Unauthorized, LoginError::NotAnAdmin)),
},
Outcome::Failure(f) => Outcome::Failure(f),
Outcome::Error(f) => Outcome::Error(f),
Outcome::Forward(f) => Outcome::Forward(f),
}
}
@ -520,9 +520,9 @@ impl<'r> FromRequest<'r> for NonGuestUser {
match User::from_request(req).await {
Outcome::Success(user) => match user.try_into() {
Ok(user) => Outcome::Success(user),
Err(_) => Outcome::Failure((Status::Unauthorized, LoginError::NotAnAdmin)),
Err(_) => Outcome::Error((Status::Unauthorized, LoginError::NotAnAdmin)),
},
Outcome::Failure(f) => Outcome::Failure(f),
Outcome::Error(f) => Outcome::Error(f),
Outcome::Forward(f) => Outcome::Forward(f),
}
}

View File

@ -141,7 +141,7 @@ async fn updatepw(
#[get("/logout")]
fn logout(cookies: &CookieJar<'_>, _user: User) -> Flash<Redirect> {
cookies.remove_private(Cookie::named("loggedin_user"));
cookies.remove_private(Cookie::from("loggedin_user"));
Flash::success(Redirect::to("/auth"), "Logout erfolgreich")
}

View File

@ -35,7 +35,7 @@ impl<'r> FromRequest<'r> for KioskCookie {
async fn from_request(request: &'r Request<'_>) -> request::Outcome<KioskCookie, Self::Error> {
match request.cookies().get_private("kiosk") {
Some(cookie) => request::Outcome::Success(KioskCookie(cookie.value().to_string())),
None => request::Outcome::Forward(()),
None => request::Outcome::Forward(rocket::http::Status::SeeOther),
}
}
}