mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-22 01:43:29 +01:00
Login flow working
This commit is contained in:
35
tests/in_memory_music_service.ts
Normal file
35
tests/in_memory_music_service.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
MusicService,
|
||||
Credentials,
|
||||
AuthSuccess,
|
||||
AuthFailure,
|
||||
} from "../src/music_service";
|
||||
|
||||
|
||||
export class InMemoryMusicService implements MusicService {
|
||||
users: Record<string, string> = {};
|
||||
|
||||
login({ username, password }: Credentials): AuthSuccess | AuthFailure {
|
||||
if (
|
||||
username != undefined &&
|
||||
password != undefined &&
|
||||
this.users[username] == password
|
||||
) {
|
||||
return { authToken: "token123", userId: username, nickname: username };
|
||||
} else {
|
||||
return { message: `Invalid user:${username}` };
|
||||
}
|
||||
}
|
||||
|
||||
hasUser(credentials: Credentials) {
|
||||
this.users[credentials.username] = credentials.password;
|
||||
}
|
||||
|
||||
hasNoUsers() {
|
||||
this.users = {};
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.users = {};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user