Change ND genre ids to b64 encoded strings of genre, so as to differentiate between genre name and id (#54)

This commit is contained in:
Simon J
2021-09-21 10:53:02 +10:00
committed by GitHub
parent be4fcdff24
commit d508eaebcf
8 changed files with 68 additions and 53 deletions

View File

@@ -5,6 +5,8 @@ import { pipe } from "fp-ts/lib/function";
import { ordString, fromCompare } from "fp-ts/lib/Ord";
import { shuffle } from "underscore";
import { b64Encode, b64Decode } from "../src/b64";
import {
MusicService,
Credentials,
@@ -37,9 +39,7 @@ export class InMemoryMusicService implements MusicService {
this.users[username] == password
) {
return Promise.resolve({
authToken: Buffer.from(JSON.stringify({ username, password })).toString(
"base64"
),
authToken: b64Encode(JSON.stringify({ username, password })),
userId: username,
nickname: username,
});
@@ -49,9 +49,7 @@ export class InMemoryMusicService implements MusicService {
}
login(token: string): Promise<MusicLibrary> {
const credentials = JSON.parse(
Buffer.from(token, "base64").toString("ascii")
) as Credentials;
const credentials = JSON.parse(b64Decode(token)) as Credentials;
if (this.users[credentials.username] != credentials.password)
return Promise.reject("Invalid auth token");