Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

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

0 comments on commit 7146367

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