Implemented logout and fixed loginWithCredentials

This commit is contained in:
RemixDev 2021-05-28 15:10:53 +02:00
parent b44a3e9a31
commit fee34f2b2a
5 changed files with 25 additions and 8 deletions

View File

@ -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
]

View File

@ -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()

View File

@ -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 })
}

View File

@ -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

2
webui

@ -1 +1 @@
Subproject commit bab72e36d0e7a2e20edbe41ee259ede629eb332d
Subproject commit 8479bf328cd399ed751ada61a2f5a2a9526f3930