mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-17 00:24:43 -04:00
feat(backend): handle username always in lowercase
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>
This commit is contained in:
parent
9625900d1c
commit
0a8945d934
23 changed files with 99 additions and 58 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -19,10 +19,11 @@ import databaseConfiguration, {
|
|||
} from '../config/database.config';
|
||||
import { Session } from '../users/session.entity';
|
||||
import { HEDGEDOC_SESSION } from '../utils/session';
|
||||
import { Username } from '../utils/username';
|
||||
|
||||
export interface SessionState {
|
||||
cookie: unknown;
|
||||
username?: string;
|
||||
username?: Username;
|
||||
authProvider: string;
|
||||
}
|
||||
|
||||
|
@ -58,10 +59,10 @@ export class SessionService {
|
|||
* @param sessionId The session id for which the owning user should be found
|
||||
* @return A Promise that either resolves with the username or rejects with an error
|
||||
*/
|
||||
fetchUsernameForSessionId(sessionId: string): Promise<string | undefined> {
|
||||
fetchUsernameForSessionId(sessionId: string): Promise<Username | undefined> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.typeormStore.get(sessionId, (error?: Error, result?: SessionState) =>
|
||||
error || !result ? reject(error) : resolve(result.username),
|
||||
error || !result ? reject(error) : resolve(result.username as Username),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue