mirror of
https://gitlab.com/RemixDev/deezer-js.git
synced 2025-01-29 17:48:29 +00:00
Automatically detect logged in child if possible
This commit is contained in:
parent
967defc76e
commit
fad327a195
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue