We need to use .ts only if we run inside ts-node
or other tools that use it. In all other cases, we need to
refer to the .js migration files.
Signed-off-by: David Mehren <git@herrmehren.de>
Previously, an undefined result in fetchUsernameForSessionId
was handled the same way as an error, rejecting the promise.
This fixes the behavior, only rejecting the promise if an error
is returned from the session store and properly returning
undefined if the session store returns that.
Signed-off-by: David Mehren <git@herrmehren.de>
The default log level is 'warning', so we log the final
startup message as warning to ensure it is visible by default.
Signed-off-by: David Mehren <git@herrmehren.de>
This config object was originally ported from the HD1 config,
but is not required anymore.
HD2 does not support handling TLS anymore, so it does not make
sense for it to set TLS-related headers.
The reverse proxy terminating TLS can easily set HSTS headers.
Signed-off-by: David Mehren <git@herrmehren.de>
With this commit we drop the subpath support which results in the constraint that HedgeDoc must always run on the root of a domain. This makes a lot of things in testing, rendering and security much easier.
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This was done as LDAPS us both the plural of LDAP and the common abbreviation for secure LDAP connections.
Fixes#4460
Signed-off-by: Philip Molares <philip.molares@udo.edu>
The setAdapter function checks if the websocket is closed.
If this is the case then an error is thrown and the whole process will be canceled. If the adapter isn't set before the realtime connection object is prepared then the connection will subscribe to all the events and THEN the process will be canceled. Because the MessageTransporter has no adapter (and won't get one), the connection will never get a disconnect event and clean up.
This causes the flood of "cant send message over closed websocket" messages.
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
While the DI and database initialization is running, NestJSs default logger is normally used. Our custom logger was only being initialized after DI setup is complete.
Errors encountered during DI setup were buffered and only printed after DI init was complete, or the app exited on error.
This led to the app not printing anything for a minute in certain cases.
This commit replaces the initial logger with our ConsoleLoggerService that logs everything.
After DI init is complete, that logger is replaced with a normal instance of ConsoleLoggerService that uses the real config from DI.
Fixes https://github.com/hedgedoc/hedgedoc/issues/4306
Signed-off-by: David Mehren <git@herrmehren.de>
sometimes we create revisions for notes that don't exist yet. If we try to persist a revision that is referring to a non-existing note the whole attempt crashes.
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This should make all usernames of new users into lowercase. Usernames are also searched in the DB as lowercase.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
The package caused some issues while working on other features.
Mostly because bundlers have been unable to determine the correct
websocket constructor.
So I replaced it with a more object-oriented approach.
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit replaces the "mayWrite", "mayRead" and "checkPermissionOnNote"
functions with one that returns a sortable permission value.
This is done because many places in the code need to do actions based on the fact if
the user has no, read or write access. If done with the may-functions then the permission
data need to be looked through multiple times.
Also, the whole check code is split into more functions that are tested separately and make it easier
to understand the process.
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>