mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-12 17:48:51 +08:00
fixed error
This commit is contained in:
parent
05626fda06
commit
df7e03b0df
1 changed files with 11 additions and 3 deletions
|
@ -115,6 +115,17 @@ class UserController {
|
|||
static async linkDiscord(req, res, next) {
|
||||
try {
|
||||
const { uid } = req.decodedToken;
|
||||
|
||||
let requser;
|
||||
try {
|
||||
requser = await UsersDAO.getUser(uid);
|
||||
} catch (e) {
|
||||
requser = null;
|
||||
}
|
||||
if (user?.banned === true) {
|
||||
throw new MonkeyError(403, "Banned accounts cannot link with Discord");
|
||||
}
|
||||
|
||||
let discordFetch = await fetch("https://discord.com/api/users/@me", {
|
||||
headers: {
|
||||
authorization: `${req.body.data.tokenType} ${req.body.data.accessToken}`,
|
||||
|
@ -141,9 +152,6 @@ class UserController {
|
|||
"This Discord account is already linked to a different account"
|
||||
);
|
||||
}
|
||||
if (user.banned === true) {
|
||||
throw new MonkeyError(403, "Banned accounts cannot link with Discord");
|
||||
}
|
||||
await UsersDAO.linkDiscord(uid, did);
|
||||
await BotDAO.linkDiscord(uid, did);
|
||||
return res.status(200).json({
|
||||
|
|
Loading…
Add table
Reference in a new issue