Discord Oauth2 Whitelisting Users and Showing Servers in Dashboard Issue

I’m making a Discord dashboard website and thanks to earlier help from a user for the data displaying issue. Now I am wondering that when you login with Discord Oauth2. Is it possible to only have certain people (whitelisting people via Discord User ID) access the dashboard/some pages and if there are others attempting to access and they authorize with Discord. They get a denied page error.

I’m pretty sure its possible to do with Express and Passport, I am kinda familiar with how Express works in terms of Discord Dashboard/Oauth. Just wondering over how this can be done.

Now for an Issue I have, I am trying to get one of the pages to display all the User’s Guilds which has their Server Icon, Server Name, ID, Creation etc. in the one page. I can’t seem to get it working and I tried this:

app.get("/profile", checkAuth, function(request, response) {
    
 response.render(__dirname + '/public/profile.ejs', {
  tag: request.user.username + " #" + request.user.discriminator,
  username: request.user.username,
  bannedbyuser: request.user.username + "#" + request.user.discriminator + " [" + request.user.id + "]",
  id: request.user.id,
  discrim: request.user.discriminator,
  email: request.user.email,
  locale: request.user.locale,
  connections: request.user.connections,
  guildname: request.user.guilds,
  avatar: "https://cdn.discordapp.com/avatars/" + request.user.id + "/" + request.user.avatar + ".png?size=2048",
  guildowner: request.user.guilds.owner,
});
})

and in profile.ejs (page to view the profile), I have this in one of the lines to display the guilds

<%=`${guildname}` %>

Well funny story, the [object Object] correctly numbers the amount of servers im in. My one being 96 Servers.

Project Name: natebot-evidence

For the “blacklisting users from dashboard with oauth2”, I’ve actually made a similar feature, as a “discord login” into my webpage. I may turn it into a tutorial. If you do need to take a look, give me a shout, it makes the user login through discord oauth2, makes request for information using token from the code provided by oauth2, which then returns json data of the user (username, id, email etc)

User.guild.name doesn’t work at all. Gives me a TypeError

TypeError: Cannot read property 'name' of undefined

Sure, you can send me the link/project to it. I am happy to take a look :slight_smile: