Recent and relevant, and filled with examples. Thank you kindly!

Best posts made by Laz
-
RE: Is it possible to include a person's Topic Count (or other info from the user object) on the post/topic page?
-
Is it possible to include a person's Topic Count (or other info from the user object) on the post/topic page?
Hey again.
I've spent a while messing around with many of the hooks and and templates trying to figure this out. We can already get the post count of a user with relative ease, but much of the information from the user object is missing from the user object that we access via
{posts.user}
.I was wondering if we could add fields from the main user object (the ones you'd see at
/api/user/Person1
) to the other object (more specifically, if it is possible, which hooks I'd need to access and a general method).
Latest posts made by Laz
-
Unable To Update NodeBB Schema
Hey friends. So. I reinstalled my forums after I accidentally deleted some stuff I wasn't meant to, and now stuff is properly borked. I completely cleaned NodeBB and MongoDB from the system.
I'm running off the master branch, and I'm fairly certain that the db search plugin is to blame, as the issue only occurs after installing that. I'm working off the master branch and upon restarting after activating that plugin, I'm met with the following error:
2019-08-11T09:44:59.042Z [4567/8372] - error: Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec: 2019-08-11T09:44:59.042Z [4567/8372] - error: ./nodebb upgrade [cluster] Child Process (8372) has exited (code: 0, signal: null)
That's fine, but when I go to run the upgrade, I get the following:
[2018/11/26] Changing dbsearch mongodb search schema to use _id... 2019-08-11T09:46:07.205Z [4567/8392] - error: ns not found {"ok":0,"errmsg":"ns not found","code":26,"codeName":"NamespaceNotFound","name":"MongoError"} 2019-08-11T09:46:07.207Z [4567/8392] - error: ns not found {"ok":0,"errmsg":"ns not found","code":26,"codeName":"NamespaceNotFound","name":"MongoError"}
and that leaves me pretty stuck. I've disabled the plugin for now, but I'd really like to know what's going on here.
-
How would I go about preventing users (non Admins/Mods) from uploading their own profile covers?
As the title says, I'm trying to make it so only admins/mods can upload or adjust the cover images for people's profiles. I've looked around the various hooks and what not, but I'm at a loss of how to achieve this.
I was originally thinking I could edit the function of the upload/edit buttons and check if the person has the required permissions; but I cannot seem to find where their functionality is actually defined.
-
RE: Using The Build Hook on Tpl Files That Are Inside Folders
Beautiful. Thanks a bunch!
-
RE: Using The Build Hook on Tpl Files That Are Inside Folders
Alright, understood. I wasn't sure how it worked then it seems. Is there a 'global' build hook? Something that is fired on every page?
-
Using The Build Hook on Tpl Files That Are Inside Folders
Hey again. When trying to run the build hook on a template file that is inside a folder, it doesn't seem to be run.
I have the following structure for my example:
Root Folder: Template -
File 1: users.tpl -
Subfolder: Partials -
File 2: users_list.tplIf I was to use the following hooks:
{ "hook": "filter:users.build", "method": "usersBuild" }, { "hook": "filter:user_list.build", "method": "userListBuild" }
The first hook would be executed, but the second one would not.
Is there something I am missing / not understanding? -
RE: Restricting Write API Access
If it were a bot, I could assign it a token from the ACP. I am creating a third party application that interfaces with NodeBB. It needs to be able to inherently create new user accounts, and then also login as them (which is where logging in via a token would come into play). I suppose it would be possible to create an account via a socket connection directly, but I imagine I could have uses to some of the write API methods anyways.
Is it possible to programmatically create user tokens for the Write API? If that's the case, I could use a socket to create the account, and then generate a JWT token specifically for that user rather than hacking something into the application itself. That would leave the only hurdle being logging in, but at that point I could just store encrypted login credentials in a config file, and login to the API using https://github.com/NicolasSiver/nodebb-plugin-ns-login
-
Restricting Write API Access
Hello again, people must be getting annoyed with my questions by this point.
I was wondering if it is possible to setup the write API plugin so that a user can only have access to certain routes. Specifically, I am looking to create a user token, that only has the ability to create other users. I have a third party application that someone can login to the forums with and, if they lack an account, create new accounts with.
Due to how the write API functions, or at least from what I can gather, once they have a token they can do anything their user can do. Is there a way to achieve what I am attempting, or perhaps a better method?
P.S. As a side note, and probably something that should be it's own topic, is it possible to login to the API/forums via a token based system? I want a user to be able to login with their username and password then store a token or something similar that will 'keep them logged in' as it were as long as the token is valid. I'd imagine doing this by storing the token, then logging in via the token itself, instead of a username/password.
-
RE: Is it possible to remove the ability to switch themes from the Admin CP?
That's probably the approach I'll take. I was just wondering if there was some inbuilt functionality, but it's not much work to do, so thanks. Have a nice day!
-
RE: Is it possible to remove the ability to switch themes from the Admin CP?
@omega Hi. I'm developing locally, but the theme does a lot of stuff that links it with the rest of our infrastructure. While I'm not expecting someone to do it, you can never be to careful if someone does something stupid. I'd rather have contingencies than relying on people not to let the curiosity get the better of them.
-
Is it possible to remove the ability to switch themes from the Admin CP?
I am designing a theme for a forum from scratch and I'm worried that an admin there might turn it switch it accidentally at some point and absolutely break everything. Is there a way to prevent this?