#Discord OAuth2 Issues - Requesting Help

2 messages · Page 1 of 1 (latest)

warped ginkgo

Can somebody help me with my Discord OAuth Script

I want to make it so that if the username for the person is 'connorplayz' they they get sent to the dashboard page, if it's not connorplayz they get sent to a different page, however if I login and the username isn't connorplayz it still sends me to the dashboard.

This is from my friend, He asked me do do this because he can't join the server for some reason

const path = require('path');
const express = require('express');

const app = express();
const port = 53134;

app.use(express.static(path.join(__dirname, 'public')));

app.get('/', (request, response) => {
  const username = response.query.username;
  if (username === 'connorplayz') {
    return response.redirect('/auth/discord');
  } else {
    return response.redirect('/noaccess.html');
  }
});

app.get('/auth/discord', (request, response) => {
  const username = response.query.username;
  if (username === 'connorplayz') {
    return response.sendFile(path.join(__dirname, 'dashboard.html'));
  } else {
    return response.redirect('/noaccess.html');
  }
});

app.get('/noaccess.html', (request, response) => {
  return response.sendFile(path.join(__dirname, 'noaccess.html'));
});

app.listen(port, () => {
  console.log(`App listening at http://localhost:${port}`);
});

quasi citrusBOT
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP