Skip to content

Commit f5f718a

Browse files
NickJ-7010C4illin
authored andcommitted
Use a new env variable to determine whether the user ID should be set to 0 for unauthenticated users
1 parent 4c36a95 commit f5f718a

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,19 @@ If you get unable to open database file run `chown -R $USER:$USER path` on the p
8080

8181
All are optional, JWT_SECRET is recommended to be set.
8282

83-
| Name | Default | Description |
84-
| ------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
85-
| JWT_SECRET | when unset it will use the value from randomUUID() | A long and secret string used to sign the JSON Web Token |
86-
| ACCOUNT_REGISTRATION | false | Allow users to register accounts |
87-
| HTTP_ALLOWED | false | Allow HTTP connections, only set this to true locally |
88-
| ALLOW_UNAUTHENTICATED | false | Allow unauthenticated users to use the service, only set this to true locally |
89-
| AUTO_DELETE_EVERY_N_HOURS | 24 | Checks every n hours for files older then n hours and deletes them, set to 0 to disable |
90-
| WEBROOT | | The address to the root path setting this to "/convert" will serve the website on "example.com/convert/" |
91-
| FFMPEG_ARGS | | Arguments to pass to ffmpeg, e.g. `-preset veryfast` |
92-
| HIDE_HISTORY | false | Hide the history page |
93-
| LANGUAGE | en | Language to format date strings in, specified as a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) |
83+
| Name | Default | Description |
84+
| ---------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
85+
| JWT_SECRET | when unset it will use the value from randomUUID() | A long and secret string used to sign the JSON Web Token |
86+
| ACCOUNT_REGISTRATION | false | Allow users to register accounts |
87+
| HTTP_ALLOWED | false | Allow HTTP connections, only set this to true locally |
88+
| ALLOW_UNAUTHENTICATED | false | Allow unauthenticated users to use the service, only set this to true locally |
89+
| AUTO_DELETE_EVERY_N_HOURS | 24 | Checks every n hours for files older then n hours and deletes them, set to 0 to disable |
90+
| WEBROOT | | The address to the root path setting this to "/convert" will serve the website on "example.com/convert/" |
91+
| FFMPEG_ARGS | | Arguments to pass to ffmpeg, e.g. `-preset veryfast` |
92+
| HIDE_HISTORY | false | Hide the history page |
93+
| LANGUAGE | en | Language to format date strings in, specified as a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) |
94+
| UNAUTHENTICATED_USER_SHARING | false | Shares conversion history between all unauthenticated users |
95+
9496

9597
### Docker images
9698

compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ services:
1515
# - WEBROOT=/convertx # the root path of the web interface, leave empty to disable
1616
# - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false
1717
- TZ=Europe/Stockholm # set your timezone, defaults to UTC
18+
# - UNAUTHENTICATED_USER_SHARING=true # for use with ALLOW_UNAUTHENTICATED=true to share history with all unauthenticated users / devices
1819
ports:
1920
- 3000:3000

src/helpers/env.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ export const WEBROOT = process.env.WEBROOT ?? "";
1616

1717
export const LANGUAGE = process.env.LANGUAGE?.toLowerCase() || "en";
1818

19-
export const MAX_CONVERT_PROCESS = process.env.MAX_CONVERT_PROCESS && Number(process.env.MAX_CONVERT_PROCESS) > 0 ? Number(process.env.MAX_CONVERT_PROCESS) : 0
19+
export const MAX_CONVERT_PROCESS = process.env.MAX_CONVERT_PROCESS && Number(process.env.MAX_CONVERT_PROCESS) > 0 ? Number(process.env.MAX_CONVERT_PROCESS) : 0
20+
21+
export const UNAUTHENTICATED_USER_SHARING =
22+
process.env.UNAUTHENTICATED_USER_SHARING?.toLowerCase() === "true" || false;

src/pages/root.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
ALLOW_UNAUTHENTICATED,
1313
HIDE_HISTORY,
1414
HTTP_ALLOWED,
15+
UNAUTHENTICATED_USER_SHARING,
1516
WEBROOT,
1617
} from "../helpers/env";
1718
import { FIRST_RUN, userService } from "./user";
@@ -33,7 +34,7 @@ export const root = new Elysia()
3334
let user: ({ id: string } & JWTPayloadSpec) | false = false;
3435
if (ALLOW_UNAUTHENTICATED) {
3536
const newUserId = String(
36-
ACCOUNT_REGISTRATION ? randomInt(2 ** 24, Math.min(2 ** 48 + 2 ** 24 - 1, Number.MAX_SAFE_INTEGER)) : 0,
37+
UNAUTHENTICATED_USER_SHARING ? 0 : randomInt(2 ** 24, Math.min(2 ** 48 + 2 ** 24 - 1, Number.MAX_SAFE_INTEGER)),
3738
);
3839
const accessToken = await jwt.sign({
3940
id: newUserId,

0 commit comments

Comments
 (0)