Add: 修改
This commit is contained in:
@@ -2,6 +2,7 @@ import {
|
||||
deleteTimeRange,
|
||||
getLimit,
|
||||
authenticate,
|
||||
update,
|
||||
updateUsername,
|
||||
updateUsernameWithLimit,
|
||||
} from "../../../../libs/db";
|
||||
@@ -34,26 +35,28 @@ export default function handler(req, res) {
|
||||
|
||||
// update username
|
||||
} else if (req.method === "PUT") {
|
||||
// check if id is valid
|
||||
// check if username is valid
|
||||
const { username } = req.body;
|
||||
if (username === undefined) {
|
||||
res.status(400).json({
|
||||
error: `缺少参数 username`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// admin update username
|
||||
const { token } = req.body;
|
||||
if (authenticate(token)) {
|
||||
updateUsername.run(username, id);
|
||||
const { name, username, id, range } = req.body;
|
||||
const result = update.run(name, range, username, id);
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// check if id is valid
|
||||
// check if username is valid
|
||||
if (username === undefined) {
|
||||
res.status(400).json({
|
||||
error: `缺少参数 username`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const limit = getLimit();
|
||||
updateUsernameWithLimit(username, id, limit);
|
||||
|
||||
Reference in New Issue
Block a user