Merge branch 'main' of gitlab.com:PhilippHofer/rot
This commit is contained in:
commit
b7c370bbde
1
shame.txt
Normal file
1
shame.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
2023-06-06: Phil Baillon um 19:10 für 18 Uhr Fahrt abgemeldet
|
@ -279,6 +279,6 @@ mod test {
|
|||||||
let pool = testdb!();
|
let pool = testdb!();
|
||||||
|
|
||||||
let actual = PlannedEvent::get_ics_feed(&pool).await;
|
let actual = PlannedEvent::get_ics_feed(&pool).await;
|
||||||
assert_eq!("BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//rudernlinz.at//Trips//DE\nX-WR-CALNAME:Ruderausfahrten\nBEGIN:VEVENT\nUID:1@rudernlinz.at\nDTSTART;TZID=Europe/Vienna:19700101T100000\nSUMMARY:test-planned-event\nEND:VEVENT\nEND:VCALENDAR", actual);
|
assert_eq!("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:ics-rs\r\nBEGIN:VEVENT\r\nUID:1@rudernlinz.at\r\nDTSTAMP:19900101T180000\r\nDTSTART:19700101T100000\r\nSUMMARY:test-planned-event\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,13 @@ use std::ops::Deref;
|
|||||||
use argon2::{password_hash::SaltString, Argon2, PasswordHasher};
|
use argon2::{password_hash::SaltString, Argon2, PasswordHasher};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
async_trait,
|
async_trait,
|
||||||
http::Status,
|
http::{Cookie, Status},
|
||||||
request::{self, FromRequest, Outcome},
|
request::{self, FromRequest, Outcome},
|
||||||
|
time::{Duration, OffsetDateTime},
|
||||||
Request,
|
Request,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json::json;
|
||||||
use sqlx::{FromRow, SqlitePool};
|
use sqlx::{FromRow, SqlitePool};
|
||||||
|
|
||||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||||
@ -178,6 +180,12 @@ impl<'r> FromRequest<'r> for User {
|
|||||||
Ok(user) => {
|
Ok(user) => {
|
||||||
let db = req.rocket().state::<SqlitePool>().unwrap();
|
let db = req.rocket().state::<SqlitePool>().unwrap();
|
||||||
user.logged_in(db).await;
|
user.logged_in(db).await;
|
||||||
|
|
||||||
|
let user_json: String = format!("{}", json!(user));
|
||||||
|
let mut cookie = Cookie::new("loggedin_user", user_json);
|
||||||
|
cookie.set_expires(OffsetDateTime::now_utc() + Duration::weeks(12));
|
||||||
|
req.cookies().add_private(cookie);
|
||||||
|
|
||||||
Outcome::Success(user)
|
Outcome::Success(user)
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -5,7 +5,9 @@ use rocket::{
|
|||||||
post,
|
post,
|
||||||
request::FlashMessage,
|
request::FlashMessage,
|
||||||
response::{Flash, Redirect},
|
response::{Flash, Redirect},
|
||||||
routes, FromForm, Route, State,
|
routes,
|
||||||
|
time::{Duration, OffsetDateTime},
|
||||||
|
FromForm, Route, State,
|
||||||
};
|
};
|
||||||
use rocket_dyn_templates::{context, tera, Template};
|
use rocket_dyn_templates::{context, tera, Template};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
@ -96,7 +98,9 @@ async fn updatepw(
|
|||||||
user.update_pw(db, updatepw.password).await;
|
user.update_pw(db, updatepw.password).await;
|
||||||
|
|
||||||
let user_json: String = format!("{}", json!(user));
|
let user_json: String = format!("{}", json!(user));
|
||||||
cookies.add_private(Cookie::new("loggedin_user", user_json));
|
let mut cookie = Cookie::new("loggedin_user", user_json);
|
||||||
|
cookie.set_expires(OffsetDateTime::now_utc() + Duration::weeks(12));
|
||||||
|
cookies.add_private(cookie);
|
||||||
|
|
||||||
Log::create(db, format!("User {} set her password.", user.name)).await;
|
Log::create(db, format!("User {} set her password.", user.name)).await;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user