Login flow working

This commit is contained in:
simojenki
2021-02-24 20:54:05 +11:00
parent c26a325ee1
commit f295d3f015
13 changed files with 416 additions and 63 deletions

View File

@@ -8,13 +8,27 @@ const t = Md5.hashStr(`${process.env["BONOB_PASSWORD"]}${s}`);
export type Credentials = { username: string, password: string }
export function isSuccess(authResult: AuthSuccess | AuthFailure): authResult is AuthSuccess {
return (authResult as AuthSuccess).authToken !== undefined;
}
export type AuthSuccess = {
authToken: string
userId: string
nickname: string
}
export type AuthFailure = {
message: string
}
export interface MusicService {
login(credentials: Credentials): boolean
login(credentials: Credentials): AuthSuccess | AuthFailure
}
export class Navidrome implements MusicService {
login(_: Credentials) {
return false
login({ username }: Credentials) {
return { authToken: `${username}`, userId: username, nickname: username }
}
ping = (): Promise<boolean> =>