Skip to content
This repository
Browse code

Daten auf der Profilseite anzeigen und with-user wrapper hinzugefügt

  • Loading branch information...
commit 71463677efc7e5cf7825c5ac915baa7db70958b4 1 parent 4945449
FossiFoo FossiFoo authored
2  src/clj_hh/core.clj
@@ -12,7 +12,7 @@
12 12
13 13 (compojure/defroutes clj-hh-routes
14 14 (compojure/GET "/" _ index-handler/show-index)
15   - (compojure/GET "/profile" _ (session/only-logged-in profile-handler/show-profile))
  15 + (compojure/GET "/profile" _ (session/only-logged-in (session/with-user profile-handler/show-profile)))
16 16 (compojure/GET "/login" _ login-handler/handle-login)
17 17 (compojure/GET "/logout" _ login-handler/handle-logout)
18 18 (compojure/GET "/test/login" _ (session/only-logged-in
8 src/clj_hh/handler/profile.clj
... ... @@ -1,6 +1,10 @@
1 1 (ns clj-hh.handler.profile
2 2 (:require
3   - [net.cgrand.enlive-html :as html]))
  3 + [net.cgrand.enlive-html :as html]
  4 + [clj-hh.session :as session]))
4 5
5 6 (html/deftemplate show-profile "templates/profile.html"
6   - [request])
  7 + [request user]
  8 + [:span.name] (html/content (:name user))
  9 + [:span.email] (html/content (:email user)))
  10 +
5 src/clj_hh/session.clj
@@ -90,6 +90,11 @@
90 90 (apply f request params)
91 91 (response/redirect (url-utils/with-continue-url "/login" (:uri request))))))
92 92
  93 +(defn with-user
  94 + [f & params]
  95 + (fn [request]
  96 + (apply f request (current-user request) params)))
  97 +
93 98 (defn ^{:added 0.1
94 99 :doc "Wraps the application with a session stored in an encrypted cookie."}
95 100 wrap-session
4 src/templates/profile.html
@@ -11,6 +11,10 @@
11 11 <section id="header">
12 12 </section>
13 13 <h1>Profile</h1>
  14 +
  15 + <div><span>Name: </span><span class="name"></span></div>
  16 + <div><span>Email: </span><span class="email"></span></div>
  17 +
14 18 <script type="text/javascript">
15 19 livereload.run();
16 20 </script>

0 comments on commit 7146367

Please sign in to comment.
Something went wrong with that request. Please try again.