Browse Source

fixed bug where 'edit' displayed on other users profile page

Akira Laine 9 years ago
parent
commit
fcd816e5d0
2 changed files with 9 additions and 2 deletions
  1. 7 0
      app/client/client.js
  2. 2 2
      app/client/templates/profile.html

+ 7 - 0
app/client/client.js

@@ -233,6 +233,13 @@ Template.profile.helpers({
             return "";
         }
     },
+    isUser: function(){
+        var parts = Router.current().url.split('/');
+        var username = parts.pop();
+        if(username === Meteor.user().profile.username){
+            return true;
+        }
+    }
 });
 
 Template.profile.onCreated(function() {

+ 2 - 2
app/client/templates/profile.html

@@ -12,7 +12,7 @@
                     <div class="panel-heading">Basic Info</div>
                     <div class="panel-body">
                         <ul>
-                            {{#if currentUser}}
+                            {{#if isUser}}
                                 <a href="#" id="edit-name" class="profile-action">Edit</a>
                                 <a href="#" id="cancel-edit" class="profile-action" style="display:none;">Cancel</a>
                             {{/if}}
@@ -20,7 +20,7 @@
                             <div id="name-div" style="display: none">
                                 <input type="text" id="input-name"><button id="submit-name" class="btn btn-primary btn-sm">Submit</button>
                             </div>
-                            {{#if currentUser}}
+                            {{#if isUser}}
                                 <a href="#" id="edit-username" class="profile-action">Edit</a>
                                 <a href="#" id="cancel-username" class="profile-action" style="display:none;">Cancel</a>
                             {{/if}}