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?
-
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 theyourid
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