mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
user email instead of username
This commit is contained in:
parent
6dfa1d84c5
commit
49f53e5a49
1 changed files with 9 additions and 9 deletions
|
@ -21,7 +21,7 @@ class SubDlApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi {
|
||||||
override val name = "SubDL"
|
override val name = "SubDL"
|
||||||
override val icon = R.drawable.subdl_logo_big
|
override val icon = R.drawable.subdl_logo_big
|
||||||
override val requiresPassword = true
|
override val requiresPassword = true
|
||||||
override val requiresUsername = true
|
override val requiresEmail = true
|
||||||
override val createAccountUrl = "https://subdl.com/login"
|
override val createAccountUrl = "https://subdl.com/login"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -42,11 +42,11 @@ class SubDlApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi {
|
||||||
currentSession = getAuthKey()
|
currentSession = getAuthKey()
|
||||||
}
|
}
|
||||||
override suspend fun login(data: InAppAuthAPI.LoginData): Boolean {
|
override suspend fun login(data: InAppAuthAPI.LoginData): Boolean {
|
||||||
val username = data.username ?: throw ErrorLoadingException("Requires Username")
|
val email = data.email ?: throw ErrorLoadingException("Requires Email")
|
||||||
val password = data.password ?: throw ErrorLoadingException("Requires Password")
|
val password = data.password ?: throw ErrorLoadingException("Requires Password")
|
||||||
switchToNewAccount()
|
switchToNewAccount()
|
||||||
try {
|
try {
|
||||||
if (initLogin(username, password)) {
|
if (initLogin(email, password)) {
|
||||||
registerAccount()
|
registerAccount()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ class SubDlApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi {
|
||||||
override fun getLatestLoginData(): InAppAuthAPI.LoginData? {
|
override fun getLatestLoginData(): InAppAuthAPI.LoginData? {
|
||||||
val current = getAuthKey() ?: return null
|
val current = getAuthKey() ?: return null
|
||||||
return InAppAuthAPI.LoginData(
|
return InAppAuthAPI.LoginData(
|
||||||
username = current.user,
|
email = current.userEmail,
|
||||||
password = current.pass
|
password = current.pass
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class SubDlApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi {
|
||||||
getAuthKey()?.let { user ->
|
getAuthKey()?.let { user ->
|
||||||
return LoginInfo(
|
return LoginInfo(
|
||||||
profilePicture = null,
|
profilePicture = null,
|
||||||
name = user.name ?: user.user,
|
name = user.name ?: user.userEmail,
|
||||||
accountIndex = accountIndex
|
accountIndex = accountIndex
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -134,12 +134,12 @@ class SubDlApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun initLogin(username: String, password: String): Boolean {
|
private suspend fun initLogin(useremail: String, password: String): Boolean {
|
||||||
|
|
||||||
val tokenResponse = app.post(
|
val tokenResponse = app.post(
|
||||||
url = "$APIURL/login",
|
url = "$APIURL/login",
|
||||||
data = mapOf(
|
data = mapOf(
|
||||||
"email" to username,
|
"email" to useremail,
|
||||||
"password" to password
|
"password" to password
|
||||||
)
|
)
|
||||||
).parsedSafe<OAuthTokenResponse>()
|
).parsedSafe<OAuthTokenResponse>()
|
||||||
|
@ -157,7 +157,7 @@ class SubDlApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi {
|
||||||
|
|
||||||
setAuthKey(
|
setAuthKey(
|
||||||
SubtitleOAuthEntity(
|
SubtitleOAuthEntity(
|
||||||
user = username,
|
userEmail = useremail,
|
||||||
pass = password,
|
pass = password,
|
||||||
name = tokenResponse.userData?.username ?: tokenResponse.userData?.name,
|
name = tokenResponse.userData?.username ?: tokenResponse.userData?.name,
|
||||||
accessToken = tokenResponse.token,
|
accessToken = tokenResponse.token,
|
||||||
|
@ -181,7 +181,7 @@ class SubDlApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SubtitleOAuthEntity(
|
data class SubtitleOAuthEntity(
|
||||||
var user: String,
|
var userEmail: String,
|
||||||
var pass: String,
|
var pass: String,
|
||||||
var name: String? = null,
|
var name: String? = null,
|
||||||
var accessToken: String? = null,
|
var accessToken: String? = null,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue