Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
fix api bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tovade committed Apr 24, 2022
1 parent 9a60cf0 commit 83286f2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions handlers/api/email/set_coins.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable camelcase */
/* eslint-disable no-mixed-operators */
module.exports.load = async function (app, ifValidAPI, ejs) {
app.post("/api/users/set_coins/email/:email", async (req, res) => {
app.post('/api/users/set_coins/email/:email', async (req, res) => {
if (
(req.session.data && req.session.data.panelinfo.root_admin) ||
ifValidAPI(req, res, "set coins")
ifValidAPI(req, res, 'set coins')
) {
if (typeof req.body !== "object")
if (typeof req.body !== 'object')
return res.json({
error: process.api_messages.core.bodymustbeanobject,
});
Expand All @@ -22,7 +22,7 @@ module.exports.load = async function (app, ifValidAPI, ejs) {

const coins = req.body.coins;

if (typeof coins !== "number")
if (typeof coins !== 'number')
return res.json({ error: process.api_messages.coins.mustbeanumber });
if (isNaN(coins))
return res.json({ error: process.api_messages.coins.cannotbenan }); // This might also not be possible.
Expand All @@ -34,7 +34,6 @@ module.exports.load = async function (app, ifValidAPI, ejs) {
res.json({
error: process.api_messages.core.noError,
coins: await process.db.setCoinsByEmail(email, coins),
user_id: user_id,
});
}
});
Expand Down

0 comments on commit 83286f2

Please sign in to comment.