@PitaJ It seems that app.user store the current user informations.
But I want the informations of the user profile that I chose to show/visit.
@PitaJ It seems that app.user store the current user informations.
But I want the informations of the user profile that I chose to show/visit.
@Dinendal
So we can do this :
var uidProfile = data.req.res.locals.uid;
console.log("\nProfile UID :"+uidProfile);
User.getUserField(uidProfile, 'userslug', function(err, userslug) {
console.log("\nUserslug :"+userslug);
});
Now I'm searching if there's another way to get this var than sending this with socket.
I saw some [[global...]] tags in tpl files whose are probably the answer.
Find out the answer to my main question :
In the Controllers.render I have forgotten this piece of code :
if (res.locals.uid !== req.user.uid) {
return res.render('403', {});
}
Still searching for these questions :
Hello,
I created a plugin that add an item in the profile menu :
plugin.addProfileItem = function (data, callback) {
data.links.push({
id: 'myplugin',
route: 'myplugin',
icon: 'fa-bar-chart',
name: "My Plugin",
visibility: {
self: true,
other: true,
moderator: true,
globalMod: true,
admin: true,
}
});
callback(null, data);
};
The purpose is to allow other users to see the new page of the user of their choice.
With the visibility attribute, other users see the item in the menu but when they click on it :
Access Denied
You seem to have stumbled upon a page that you do not have access to.
My main question is : Where could I set up access rights in this case ?
Two more questions :
@baris Didn't work. I will use type="date".
Thanks.
@baris It's working when I reload but it's not working on the initial load
@julian I'm using a text type because date type seems to be in DD/MM/YYYY format and I want to force MM/DD/YYYY format for international users (it's maybe depend of navigator language config). Also, the skin of date-picker looks better. I'm open to solutions for these 2 problems eventually (i'm going to do some research about that).
@baris
I tried your solution by doing this :
$(window).on('action:ajaxify.end', initDate());
function initDate(){
app.loadJQueryUI(function () {
$( "#filter_date1" ).datepicker();
$( "#filter_date2" ).datepicker();
});
}
and got this error on the $(window) line :
Uncaught ReferenceError: $ is not defined
No clue ?
Do you need more details ?
Hi everybody,
I have created a plugin to add a page in the user profile.
I have added an item in the profile menu to go to this page and it works fine.
When I click on this item my page is correctly loaded with my custom tpl where i write :
app.loadJQueryUI(function () {
$( "#filter_date1" ).datepicker();
$( "#filter_date2" ).datepicker();
});
This code define 2 fields with a calendar to allow user to filter informations on this page.
But if I reload the page pressing "F5" for example, there is this error :
Uncaught TypeError: app.loadJQueryUI is not a function
Could someone explain to me what's the difference in nodebb process, why this error occur and how to fix this please ?
Thank you.
Dinendal.
@julian So the way to achieve that, is to use the library on the client side and to request data with socket.io, i think.
Is it possible to integrate JS file from the node_modules directory in the page with tags <script></script> ? Can't find the path.
I use a copy of chart.js in the public directory : /uploads/script/chart.js
@julian I tried to add the same code as the admin panel in my plugin but I always got the same error :
ReferenceError: document is not defined
What's the trick to use "document" and use/modify elements on server side ?
@baris Ok, but I don't understand how this could work on server side, for example :
var trafficCanvas = document.getElementById('analytics-traffic');
@baris Ok thanks, i'll see that.
How nodejs interact with the DOM to create/update charts in the admin panel ?
I searched in the code but I can't see where "document" is declared.
Is there a way to do this with JSDOM or it's managed in another way ?
chart.js need the context so :
var ctx = document.getElementById("myChart");
But from the server side document is undefined, so I tried some declaration :
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const { document } = new JSDOM(IDontReallyKnowWhatToPutInHere);
Could you explain to me how this works or link me an example of this from NodeBB please ? Because I can't see anything in dashboard.js about that.
@julian Thanks a lot.
Is there a way to use a hook when this page created by the plugin is built ? I tried several sorts of config with ".build" hooks (like : "filter:account.myPluginTPL.build") but it seems to not work like a "static" page or I did not really understand.
EDIT : Ok I found a solution.
I use the hook : "filter:middleware.render" and add a condition with match function to be sure that's my new page loading.
@julian Perfect ! It's a very good example.
Another question, i need some Charts on this page. I saw that the chart.js plugin is used in the admin dashboard.
I saw the TPL file who "draw" this page too (dashboard.tpl), but could you show me from where these charts are created please ? I can't find the JS file.
Hello,
How could I add a page in the user profile ?
I saw that each url's page of the profile is like /user/MyUserName/MyPage
Is it possible to create this page via the plugin "custom pages" ?
I tried, but it's not a static url because of the username.
And, in addition of this, is it possible to add a link to this new page in the "..." menu of the profile ?
If someone already done this or if you could give me a link for explanations
Thanks.
Thanks, it's working, i have juste corrected user in User.
Another question again : is it possible to force refresh of the page to make sure that the change of username is correct ?
Hello,
I wrote a plugin to login my users from another app to my NodeBB forum.
In my app, my users are allowed to change their usernames so I overwrite user's field by using this :
User.setUserField(uid, 'username', username);
User.setUserField(uid, 'userslug', utils.slugify(username));
It's working, but when the user go to his profile, there is an error.
The profile can be found by changing the username (userslug) in the URL by the old one.
How could I make this work entirely ?
Another question : where could I found the list of allowed characters in NodeBB's username ? It seems that "(" is not allowed for example.
Thanks.
translation of the error : "It looks like your login session is no longer active, or no longer recognized by your server..."
Is there a step that i'm missing ? Because when I click on "OK", I'm logged in...
"authenticationController.doLogin" is not sufficient ?