Automatically detect logged in child if possible

This commit is contained in:
RemixDev 2021-08-18 14:43:20 +02:00
parent 967defc76e
commit fad327a195

View file

@ -41,7 +41,8 @@ class Deezer{
this.http_headers['Accept-Language'] = lang
}
async login(email, password, re_captcha_token, child=0){
async login(email, password, re_captcha_token, child){
if (child) child = parseInt(child)
// Check if user already logged in
let user_data = await this.gw.get_user_data()
if (user_data.USER.USER_ID == 0){
@ -68,13 +69,15 @@ class Deezer{
}
user_data = await this.gw.get_user_data()
await this._post_login(user_data)
if (!child && user_data.USER.MULTI_ACCOUNT.CHILD_COUNT) child = (user_data.USER.MULTI_ACCOUNT.CHILD_COUNT -1) || 0
this.change_account(child)
this.logged_in = true
return true
}
async login_via_arl(arl, child=0){
async login_via_arl(arl, child){
arl = arl.trim()
if (child) child = parseInt(child)
// Create cookie
let cookie_obj = new Cookie({
@ -93,6 +96,7 @@ class Deezer{
return false
}
await this._post_login(user_data)
if (!child && user_data.USER.MULTI_ACCOUNT.CHILD_COUNT) child = (user_data.USER.MULTI_ACCOUNT.CHILD_COUNT -1) || 0
this.change_account(child)
this.logged_in = true
return true