فهرست منبع

Make use of logged-in-user information.

Frederic G. MARAND 9 سال پیش
والد
کامیت
868d78e3e2
2فایلهای تغییر یافته به همراه12 افزوده شده و 2 حذف شده
  1. 4 2
      image_share.html
  2. 8 0
      image_share.js

+ 4 - 2
image_share.html

@@ -12,7 +12,7 @@
   </nav>
 
   <div class="container">
-    <h1>Welcome to image share!</h1>
+    <h1>Welcome to image share {{ username }} !</h1>
 
     {{> images}}
   </div>
@@ -44,7 +44,9 @@
 </template>
 
 <template name="images">
-  <button class="btn btn-success js-show-image-form">add image</button>
+  {{#if currentUser }}
+    <button class="btn btn-success js-show-image-form">add image</button>
+  {{/if}}
   <div class="row">
     {{#each images}}
       <div class="col-xs-12 col-md-3" id="{{_id}}">

+ 8 - 0
image_share.js

@@ -9,6 +9,14 @@ if (Meteor.isClient) {
     }
   });
 
+  Template.body.helpers({
+    username: function () {
+      let user = Meteor.user();
+      let name = user ? user.emails[0].address : "anon";
+      return name;
+    }
+  });
+
   Template.images.events({
     "click .js-image": function (event) {
       $(event.target).css("width", "50px");