about summary refs log tree commit diff
path: root/src/render.rs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2018-05-01T21·00+0200
committerVincent Ambo <github@tazj.in>2018-05-01T22·33+0200
commit40fb4ebbb9c88754bafc9b115841712ad023d099 (patch)
tree209a2e9936651efb207bfc23d18eb723c6e1be0b /src/render.rs
parent6d69f5001eb7d4fdd9e791933b2dfd135f5819e7 (diff)
refactor(handlers/render): Use users from database for all functions
Converse now sets the user ID as the session identity parameter in
actix_web's identity middleware after a successful login and uses the
ID to determine identity when creating threads & posts and when
validating edit permissions.
Diffstat (limited to 'src/render.rs')
-rw-r--r--src/render.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/render.rs b/src/render.rs
index bc1197bc15f1..63a89d99ee31 100644
--- a/src/render.rs
+++ b/src/render.rs
@@ -87,7 +87,7 @@ impl Handler<IndexPage> for Renderer {
 
 /// Message used to render a thread.
 pub struct ThreadPage {
-    pub current_user: Option<String>,
+    pub current_user: i32,
     pub thread: Thread,
     pub posts: Vec<SimplePost>,
 }
@@ -122,9 +122,7 @@ fn prepare_thread(comrak: &ComrakOptions, page: ThreadPage) -> RenderableThreadP
     let user = page.current_user;
 
     let posts = page.posts.into_iter().map(|post| {
-        let editable = user.clone()
-            .map(|c| post.author_email.eq(&c))
-            .unwrap_or_else(|| false);
+        let editable = user != 1 && post.user_id == user;
 
         RenderablePost {
             id: post.id,