Skip to content

Commit

Permalink
v1.0.1: Fix config gen for users that haven't logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
Neztore committed Apr 4, 2020
1 parent 1518054 commit 61d9322
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "save-server",
"version": "1.0.0",
"version": "1.0.1",
"description": "A ShareX server built on Express, Bulma and SQLite with User support.",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 8 additions & 3 deletions server/api/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,19 @@ users.delete("/:id", errorCatch(async function (req, res, next) {
res.send({ success: true, message: "User deleted." });
}));

users.get("/:id/config", function (req, res) {
users.get("/:id/config", errorCatch(async function (req, res) {
// Generate config
const isLink = req.query.link && req.query.link === "true";
const urlBase = `${getBase(req)}/api`;
let token = req.target.token;
if (!token) {
token = await generateToken();
await db.setToken(req.target.username, token);
}
const config = {
Version: "12.4.1",
Headers: {
Authorization: req.target.token
Authorization: token
},
RequestMethod: "POST",
URL: "$json:url$",
Expand All @@ -194,7 +199,7 @@ users.get("/:id/config", function (req, res) {
res.setHeader("content-type", "application/sxcu");
const stringified = JSON.stringify(config, null, "\t");
res.send(stringified);
});
}));

users.patch("/:id/password", errorCatch(async function (req, res) {
// ID being @me or an ID.
Expand Down

0 comments on commit 61d9322

Please sign in to comment.