about summary refs log tree commit diff
path: root/src/handlers.rs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2018-04-15T10·38+0200
committerVincent Ambo <tazjin@gmail.com>2018-04-15T10·38+0200
commit9cee48f2dac7400fc0df78b8790ff1e1600a632e (patch)
treecd21cdad21f6dc8c046be7819564ba8d80005f00 /src/handlers.rs
parent02a466a28be4c6fdcd88075d6345841759ff630c (diff)
feat(handlers): Determine whether current user can edit a post
Diffstat (limited to 'src/handlers.rs')
-rw-r--r--src/handlers.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index ccb01eb3c803..f4346f26c6c3 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -60,11 +60,18 @@ pub fn forum_index(state: State<AppState>) -> ConverseResponse {
 }
 
 /// This handler retrieves and displays a single forum thread.
-pub fn forum_thread(state: State<AppState>, thread_id: Path<i32>) -> ConverseResponse {
+pub fn forum_thread(state: State<AppState>,
+                    mut req: HttpRequest<AppState>,
+                    thread_id: Path<i32>) -> ConverseResponse {
     let id = thread_id.into_inner();
+    let user = req.session().get(AUTHOR)
+        .unwrap_or_else(|_| None)
+        .map(|a: Author| a.email);
+
     state.db.send(GetThread(id))
         .flatten()
         .and_then(move |res| state.renderer.send(ThreadPage {
+            current_user: user,
             thread: res.0,
             posts: res.1,
         }).from_err())