Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default board, userInfo fix #286

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions server/check_output_directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ async function get_error(directory) {
if (!fs.statSync(directory).isDirectory()) {
error = "exists, but is not a directory";
}
const { uid, gid } = os.userInfo();
const tmpfile = path.join(directory, Math.random() + ".json");
try {
fs.writeFileSync(tmpfile, "{}");
fs.unlinkSync(tmpfile);
} catch (e) {
return (
"does not allow file creation and deletion. " +
"Check the permissions of the directory, and if needed change them so that " +
`user with UID ${uid} has access to them. This can be achieved by running the command: chown ${uid}:${gid} on the directory`
);
let err_msg = "does not allow file creation and deletion. ";
try {
const { uid, gid } = os.userInfo();
err_msg += "Check the permissions of the directory, and if needed change them so that " +
`user with UID ${uid} has access to them. This can be achieved by running the command: chown ${uid}:${gid} on the directory`;
} finally {
return err_msg;
}
}
const fileChecks = [];
const files = await fs.promises.readdir(directory, { withFileTypes: true });
Expand Down
3 changes: 3 additions & 0 deletions server/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@ module.exports = {

/** Secret key for jwt */
AUTH_SECRET_KEY: (process.env["AUTH_SECRET_KEY"] || ""),

/** If this variable is set, automatically redirect to this board from the root of the application. */
DEFAULT_BOARD: (process.env["WBO_DEFAULT_BOARD"]),

};
4 changes: 4 additions & 0 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ function handleRequest(request, response) {

case "": // Index page
logRequest(request);
if (config.DEFAULT_BOARD) {
response.writeHead(302, { Location: 'boards/' + encodeURIComponent(config.DEFAULT_BOARD) });
response.end(name);
} else
indexTemplate.serve(request, response);
break;

Expand Down