mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 10:15:17 -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
|
@ -11,6 +11,7 @@ import {
|
|||
import { Mock } from 'ts-mockery';
|
||||
|
||||
import { User } from '../../../users/user.entity';
|
||||
import { Username } from '../../../utils/username';
|
||||
import { RealtimeConnection } from '../realtime-connection';
|
||||
import { RealtimeNote } from '../realtime-note';
|
||||
import { RealtimeUserStatusAdapter } from '../realtime-user-status-adapter';
|
||||
|
@ -21,13 +22,13 @@ enum RealtimeUserState {
|
|||
WITH_READONLY,
|
||||
}
|
||||
|
||||
const MOCK_FALLBACK_USERNAME = 'mock';
|
||||
const MOCK_FALLBACK_USERNAME: Username = 'mock';
|
||||
|
||||
/**
|
||||
* Creates a mocked {@link RealtimeConnection realtime connection}.
|
||||
*/
|
||||
export class MockConnectionBuilder {
|
||||
private username: string | null;
|
||||
private username: Username | null;
|
||||
private displayName: string | undefined;
|
||||
private includeRealtimeUserStatus: RealtimeUserState =
|
||||
RealtimeUserState.WITHOUT;
|
||||
|
@ -50,7 +51,7 @@ export class MockConnectionBuilder {
|
|||
*
|
||||
* @param username the username of the mocked user. If this value is omitted then the builder will user a {@link MOCK_FALLBACK_USERNAME fallback}.
|
||||
*/
|
||||
public withLoggedInUser(username?: string): this {
|
||||
public withLoggedInUser(username?: Username): this {
|
||||
const newUsername = username ?? MOCK_FALLBACK_USERNAME;
|
||||
this.username = newUsername;
|
||||
this.displayName = newUsername;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue