mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-07-26 22:42:17 +00:00
cleanup trakt settings
This commit is contained in:
parent
e8c0b09aa3
commit
511accc520
1 changed files with 0 additions and 44 deletions
|
|
@ -85,31 +85,6 @@ object TraktAuthRepository {
|
|||
return buildAuthorizationUrl(oauthState)
|
||||
}
|
||||
|
||||
fun onConnectWithCodeRequested(rawInput: String) {
|
||||
ensureLoaded()
|
||||
if (!hasRequiredCredentials()) {
|
||||
publish(errorMessage = "Missing Trakt credentials")
|
||||
return
|
||||
}
|
||||
|
||||
val code = extractAuthorizationCode(rawInput)
|
||||
if (code.isNullOrBlank()) {
|
||||
publish(errorMessage = "Paste a valid Trakt authorization code or callback URL")
|
||||
return
|
||||
}
|
||||
|
||||
scope.launch {
|
||||
publish(
|
||||
isLoading = true,
|
||||
statusMessage = "Completing Trakt sign in",
|
||||
errorMessage = null,
|
||||
)
|
||||
clearPendingAuthorization()
|
||||
persist()
|
||||
exchangeAuthorizationCode(code)
|
||||
}
|
||||
}
|
||||
|
||||
fun pendingAuthorizationUrl(): String? {
|
||||
ensureLoaded()
|
||||
val oauthState = authState.pendingAuthorizationState ?: return null
|
||||
|
|
@ -451,25 +426,6 @@ object TraktAuthRepository {
|
|||
return "$AUTHORIZE_URL?response_type=$responseType&client_id=$encodedClientId&redirect_uri=$encodedRedirectUri&state=$encodedState"
|
||||
}
|
||||
|
||||
private fun extractAuthorizationCode(rawInput: String): String? {
|
||||
val input = rawInput.trim()
|
||||
if (input.isBlank()) return null
|
||||
|
||||
val urlCode = runCatching {
|
||||
Url(input)
|
||||
}.getOrNull()?.parameters?.get("code")?.trim()
|
||||
if (!urlCode.isNullOrBlank()) return urlCode
|
||||
|
||||
val regexCode = Regex("[?&]code=([^&]+)")
|
||||
.find(input)
|
||||
?.groupValues
|
||||
?.getOrNull(1)
|
||||
?.trim()
|
||||
if (!regexCode.isNullOrBlank()) return regexCode
|
||||
|
||||
return input
|
||||
}
|
||||
|
||||
private fun generateOauthState(): String {
|
||||
val nowPart = TraktPlatformClock.nowEpochMs().toString(16)
|
||||
val randomPart = Random.nextLong().toULong().toString(16)
|
||||
|
|
|
|||
Loading…
Reference in a new issue