Getting the ID of the account that I am using.



  • Hi Guys,

    I sent a tweet out yesterday asking a question and I had a reply back this morning asking me to discuss it here.

    In /public/src/forum/admin/groups.js when removing someone from a group by clicking on their username there is now confirmation on if you want to complete that action; I have added this functionality to my version of NodeBB.

    This also led me to find out that you can remove yourself from the Administrator group. I accidentally did this and was surprised I was able to.

    I am trying to add a check to groups.js that will check if the current user == the user ID that is being clicked and if it is i want the user to not be able to remove themselves from the usergroup.

    I have found that on the /public/src/forum/admin/users.js there is a variable called yourid

    var yourid = templates.get('yourid');
    

    When i try to add this to the group.js it brings back "undefined". Is there something else I am missing?

    Is there another way to check the current user id?


  • GNU/Linux Admin

    Hey @Scuzz, I answered your tweet yesterday 🙂 I just wanted a bit more detail, and you've provided it for me.

    So, take a look at /public/template/admin/users.tpl, line 91:

    <input type="hidden" template-variable="yourid" value="{yourid}" />
    

    This is the snippet of code that passes data to our custom template engine (and the corresponding javascript). You can add this to the bottom of groups.tpl, if you'd like access to the yourid variable.

    Keep in mind that you'll also have to add yourid to /src/routes/admin.js:426 as well, otherwise the view engine won't have the necessary data to pass through 🙂


  • GNU/Linux Admin

    ah... missed you by 20 minutes... but imagine trying to fit what I said above in 140 characters :S



  • @julian

    Thanks for the reply.

    I added that to the template too but it was only returning {yourid} as a value but i'm guessing that is because yourid to /src/routes/admin.js

    I will try when i am able to use my local copy.

    🙂


Log in to reply
 

Suggested Topics

  • 5
  • 3
  • 2
  • 2
  • 3
| |