Implemented logout and fixed loginWithCredentials
This commit is contained in:
parent
b44a3e9a31
commit
fee34f2b2a
@ -4,6 +4,7 @@ import loginWithCredentials from './loginWithCredentials'
|
|||||||
import cancelAllDownloads from './cancelAllDownloads'
|
import cancelAllDownloads from './cancelAllDownloads'
|
||||||
import removeFinishedDownloads from './removeFinishedDownloads'
|
import removeFinishedDownloads from './removeFinishedDownloads'
|
||||||
import removeFromQueue from './removeFromQueue'
|
import removeFromQueue from './removeFromQueue'
|
||||||
|
import logout from './logout'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
loginArl,
|
loginArl,
|
||||||
@ -11,5 +12,6 @@ export default [
|
|||||||
loginWithCredentials,
|
loginWithCredentials,
|
||||||
cancelAllDownloads,
|
cancelAllDownloads,
|
||||||
removeFinishedDownloads,
|
removeFinishedDownloads,
|
||||||
removeFromQueue
|
removeFromQueue,
|
||||||
|
logout
|
||||||
]
|
]
|
||||||
|
@ -17,7 +17,7 @@ const LoginStatus = {
|
|||||||
FORCED_SUCCESS: 3
|
FORCED_SUCCESS: 3
|
||||||
}
|
}
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/login-arl/'
|
const path: ApiHandler['path'] = '/login-arl'
|
||||||
|
|
||||||
const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, next) => {
|
const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, next) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
|
@ -4,16 +4,16 @@ import { getAccessToken, getArlFromAccessToken } from '../../../main'
|
|||||||
const path = '/loginWithCredentials'
|
const path = '/loginWithCredentials'
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
const { username, password } = req.body
|
const { email, password } = req.body
|
||||||
let accessToken = req.body.accessToken
|
let accessToken = req.body.accessToken
|
||||||
|
|
||||||
if (!accessToken){
|
if (!accessToken){
|
||||||
const accessToken = await getAccessToken(username, password)
|
accessToken = await getAccessToken(email, password)
|
||||||
console.log({ accessToken })
|
|
||||||
}
|
}
|
||||||
let arl
|
let arl
|
||||||
if (accessToken) arl = getArlFromAccessToken(accessToken)
|
if (accessToken) arl = await getArlFromAccessToken(accessToken)
|
||||||
|
|
||||||
|
console.log({ accessToken, arl })
|
||||||
res.send({ accessToken, arl })
|
res.send({ accessToken, arl })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
2
webui
@ -1 +1 @@
|
|||||||
Subproject commit bab72e36d0e7a2e20edbe41ee259ede629eb332d
|
Subproject commit 8479bf328cd399ed751ada61a2f5a2a9526f3930
|
Loading…
Reference in New Issue
Block a user