Skip to content

Commit

Permalink
Fixed Auth headers and updated the Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
p0t4t0sandwich committed Aug 2, 2023
1 parent ec41584 commit a1ac293
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A bee-themed name generator for various uses.

## Discord Bot Usage

### Command List (markdown table)
### Command List

| Command | Description | Parameters | Admin Only |
| --- | --- | --- | --- |
Expand Down
10 changes: 5 additions & 5 deletions lib/discordBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class DiscordBot {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": AUTH_TOKEN,
"Authorization": "Bearer " + AUTH_TOKEN,
},
body: JSON.stringify({ name: beeName }),
});
Expand All @@ -90,7 +90,7 @@ export class DiscordBot {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Authorization": AUTH_TOKEN,
"Authorization": "Bearer " + AUTH_TOKEN,
},
body: JSON.stringify({ name: beeName }),
});
Expand Down Expand Up @@ -143,7 +143,7 @@ export class DiscordBot {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": AUTH_TOKEN,
"Authorization": "Bearer " + AUTH_TOKEN,
}
});
const data = await response.json();
Expand All @@ -169,7 +169,7 @@ export class DiscordBot {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Authorization": AUTH_TOKEN,
"Authorization": "Bearer " + AUTH_TOKEN,
},
body: JSON.stringify({ name: beeName }),
});
Expand All @@ -196,7 +196,7 @@ export class DiscordBot {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Authorization": AUTH_TOKEN,
"Authorization": "Bearer " + AUTH_TOKEN,
},
body: JSON.stringify({ name: beeName }),
});
Expand Down
10 changes: 5 additions & 5 deletions lib/webServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ export class WebServer {

// Upload a bee name (authenticated)
async uploadBeeNameRoute(req, res, next): Promise<void> {
try {
try {
// Check if request is authenticated
if (req.headers.authorization === AUTH_TOKEN) {
if (req.headers.authorization === "Bearer " + AUTH_TOKEN) {
// Check if request body is valid
const beeName: string = req.params.name || req.body.name;

Expand Down Expand Up @@ -159,7 +159,7 @@ export class WebServer {
async deleteBeeNameRoute(req, res, next): Promise<void> {
try {
// Check if request is authenticated
if (req.headers.authorization === AUTH_TOKEN) {
if (req.headers.authorization === "Bearer " + AUTH_TOKEN) {
// Check if request body is valid
const beeName: string = req.params.name || req.body.name;

Expand Down Expand Up @@ -242,7 +242,7 @@ export class WebServer {
async getBeeNameSuggestionsRoute(req, res, next): Promise<void> {
try {
// Check if request is authenticated
if (req.headers.authorization === AUTH_TOKEN) {
if (req.headers.authorization === "Bearer " + AUTH_TOKEN) {
// Check if request body is valid
const amount: number = req.params.amount || req.body.amount || 1;

Expand Down Expand Up @@ -280,7 +280,7 @@ export class WebServer {
async acceptBeeNameSuggestionRoute(req, res, next): Promise<void> {
try {
// Check if request is authenticated
if (req.headers.authorization === AUTH_TOKEN) {
if (req.headers.authorization === "Bearer " + AUTH_TOKEN) {
// Check if request body is valid
const beeName: string = req.params.name || req.body.name;
if (beeName) {
Expand Down

0 comments on commit a1ac293

Please sign in to comment.