From fee34f2b2afc0105c692e4513ec8227a453f92cb Mon Sep 17 00:00:00 2001 From: RemixDev Date: Fri, 28 May 2021 15:10:53 +0200 Subject: [PATCH] Implemented logout and fixed loginWithCredentials --- server/src/routes/api/post/index.ts | 4 +++- server/src/routes/api/post/login-arl.ts | 2 +- .../src/routes/api/post/loginWithCredentials.ts | 10 +++++----- server/src/routes/api/post/logout.ts | 15 +++++++++++++++ webui | 2 +- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/server/src/routes/api/post/index.ts b/server/src/routes/api/post/index.ts index 74f88fa..9a6c597 100644 --- a/server/src/routes/api/post/index.ts +++ b/server/src/routes/api/post/index.ts @@ -4,6 +4,7 @@ import loginWithCredentials from './loginWithCredentials' import cancelAllDownloads from './cancelAllDownloads' import removeFinishedDownloads from './removeFinishedDownloads' import removeFromQueue from './removeFromQueue' +import logout from './logout' export default [ loginArl, @@ -11,5 +12,6 @@ export default [ loginWithCredentials, cancelAllDownloads, removeFinishedDownloads, - removeFromQueue + removeFromQueue, + logout ] diff --git a/server/src/routes/api/post/login-arl.ts b/server/src/routes/api/post/login-arl.ts index 40296aa..66417be 100644 --- a/server/src/routes/api/post/login-arl.ts +++ b/server/src/routes/api/post/login-arl.ts @@ -17,7 +17,7 @@ const LoginStatus = { FORCED_SUCCESS: 3 } -const path: ApiHandler['path'] = '/login-arl/' +const path: ApiHandler['path'] = '/login-arl' const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, next) => { if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer() diff --git a/server/src/routes/api/post/loginWithCredentials.ts b/server/src/routes/api/post/loginWithCredentials.ts index 42b8b64..9726baa 100644 --- a/server/src/routes/api/post/loginWithCredentials.ts +++ b/server/src/routes/api/post/loginWithCredentials.ts @@ -4,16 +4,16 @@ import { getAccessToken, getArlFromAccessToken } from '../../../main' const path = '/loginWithCredentials' const handler: ApiHandler['handler'] = async (req, res) => { - const { username, password } = req.body + const { email, password } = req.body let accessToken = req.body.accessToken if (!accessToken){ - const accessToken = await getAccessToken(username, password) - console.log({ accessToken }) + accessToken = await getAccessToken(email, password) } let arl - if (accessToken) arl = getArlFromAccessToken(accessToken) - + if (accessToken) arl = await getArlFromAccessToken(accessToken) + + console.log({ accessToken, arl }) res.send({ accessToken, arl }) } diff --git a/server/src/routes/api/post/logout.ts b/server/src/routes/api/post/logout.ts index e69de29..2bed3fe 100644 --- a/server/src/routes/api/post/logout.ts +++ b/server/src/routes/api/post/logout.ts @@ -0,0 +1,15 @@ +// @ts-expect-error +import { Deezer } from 'deezer-js' +import { ApiHandler } from '../../../types' +import { sessionDZ } from '../../../main' + +const path: ApiHandler['path'] = '/logout' + +const handler: ApiHandler['handler'] = async (req, res) => { + sessionDZ[req.session.id] = new Deezer() + res.send({ logged_out: true }) +} + +const apiHandler: ApiHandler = { path, handler } + +export default apiHandler diff --git a/webui b/webui index bab72e3..8479bf3 160000 --- a/webui +++ b/webui @@ -1 +1 @@ -Subproject commit bab72e36d0e7a2e20edbe41ee259ede629eb332d +Subproject commit 8479bf328cd399ed751ada61a2f5a2a9526f3930