diff --git a/src/templates/mod.rs b/src/templates/mod.rs index b73a1c8..c6dccdf 100644 --- a/src/templates/mod.rs +++ b/src/templates/mod.rs @@ -40,19 +40,15 @@ pub struct WhispersTemplate { /// The whispers to be rendered pub whispers: Vec, - /// Whether the user is authenticated or not - pub authenticated: bool, - /// The user of the instance pub user: User, } impl WhispersTemplate { /// Returns a new template with the given whispers - pub fn new(whispers: Vec, authenticated: bool) -> Self { + pub fn new(whispers: Vec) -> Self { Self { whispers, - authenticated, user: User::default(), } } @@ -64,9 +60,8 @@ pub async fn home( req: HttpRequest, database: web::Data, ) -> Result> { - let authenticated = crate::auth::validate_cookie(&req); // If the user is authenticated, show all whispers, otherwise only show public whispers. - let whispers = if authenticated { + let whispers = if crate::auth::validate_cookie(&req) { database.list().await? } else { database.list().await?.filter() @@ -75,7 +70,7 @@ pub async fn home( .rev() .collect::>(); - Ok(WhispersTemplate::new(whispers, authenticated)) + Ok(WhispersTemplate::new(whispers)) } /// The template that renders the auth page