mirror of
				https://github.com/C4illin/ConvertX.git
				synced 2025-11-04 14:03:32 +00:00 
			
		
		
		
	Use a new env variable to determine whether the user ID should be set to 0 for unauthenticated users
This commit is contained in:
		@@ -81,7 +81,7 @@ If you get unable to open database file run `chown -R $USER:$USER path` on the p
 | 
			
		||||
All are optional, JWT_SECRET is recommended to be set.
 | 
			
		||||
 | 
			
		||||
| Name                         | Default                                            | Description                                                                                                               |
 | 
			
		||||
| ------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
 | 
			
		||||
| ---------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
 | 
			
		||||
| JWT_SECRET                   | when unset it will use the value from randomUUID() | A long and secret string used to sign the JSON Web Token                                                                  |
 | 
			
		||||
| ACCOUNT_REGISTRATION         | false                                              | Allow users to register accounts                                                                                          |
 | 
			
		||||
| HTTP_ALLOWED                 | false                                              | Allow HTTP connections, only set this to true locally                                                                     |
 | 
			
		||||
@@ -91,6 +91,8 @@ All are optional, JWT_SECRET is recommended to be set.
 | 
			
		||||
| FFMPEG_ARGS                  |                                                    | Arguments to pass to ffmpeg, e.g. `-preset veryfast`                                                                      |
 | 
			
		||||
| HIDE_HISTORY                 | false                                              | Hide the history page                                                                                                     |
 | 
			
		||||
| LANGUAGE                     | en                                                 | Language to format date strings in, specified as a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) |
 | 
			
		||||
| UNAUTHENTICATED_USER_SHARING | false                                              | Shares conversion history between all unauthenticated users                                                               |
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Docker images
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -15,5 +15,6 @@ services:
 | 
			
		||||
      # - WEBROOT=/convertx # the root path of the web interface, leave empty to disable
 | 
			
		||||
      # - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false
 | 
			
		||||
      - TZ=Europe/Stockholm # set your timezone, defaults to UTC
 | 
			
		||||
      # - UNAUTHENTICATED_USER_SHARING=true # for use with ALLOW_UNAUTHENTICATED=true to share history with all unauthenticated users / devices
 | 
			
		||||
    ports:
 | 
			
		||||
      - 3000:3000
 | 
			
		||||
 
 | 
			
		||||
@@ -17,3 +17,6 @@ export const WEBROOT = process.env.WEBROOT ?? "";
 | 
			
		||||
export const LANGUAGE = process.env.LANGUAGE?.toLowerCase() || "en";
 | 
			
		||||
 | 
			
		||||
export const MAX_CONVERT_PROCESS = process.env.MAX_CONVERT_PROCESS && Number(process.env.MAX_CONVERT_PROCESS) > 0 ? Number(process.env.MAX_CONVERT_PROCESS) : 0
 | 
			
		||||
 | 
			
		||||
export const UNAUTHENTICATED_USER_SHARING =
 | 
			
		||||
  process.env.UNAUTHENTICATED_USER_SHARING?.toLowerCase() === "true" || false;
 | 
			
		||||
@@ -12,6 +12,7 @@ import {
 | 
			
		||||
  ALLOW_UNAUTHENTICATED,
 | 
			
		||||
  HIDE_HISTORY,
 | 
			
		||||
  HTTP_ALLOWED,
 | 
			
		||||
  UNAUTHENTICATED_USER_SHARING,
 | 
			
		||||
  WEBROOT,
 | 
			
		||||
} from "../helpers/env";
 | 
			
		||||
import { FIRST_RUN, userService } from "./user";
 | 
			
		||||
@@ -33,7 +34,7 @@ export const root = new Elysia()
 | 
			
		||||
    let user: ({ id: string } & JWTPayloadSpec) | false = false;
 | 
			
		||||
    if (ALLOW_UNAUTHENTICATED) {
 | 
			
		||||
      const newUserId = String(
 | 
			
		||||
        ACCOUNT_REGISTRATION ? randomInt(2 ** 24, Math.min(2 ** 48 + 2 ** 24 - 1, Number.MAX_SAFE_INTEGER)) : 0,
 | 
			
		||||
        UNAUTHENTICATED_USER_SHARING ? 0 : randomInt(2 ** 24, Math.min(2 ** 48 + 2 ** 24 - 1, Number.MAX_SAFE_INTEGER)),
 | 
			
		||||
      );
 | 
			
		||||
      const accessToken = await jwt.sign({
 | 
			
		||||
        id: newUserId,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user