Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Funkwhale Android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
funkwhale
Funkwhale Android
Commits
20ee27da
Commit
20ee27da
authored
3 years ago
by
Ryan Harg
Browse files
Options
Downloads
Patches
Plain Diff
fix authorization
parent
2bdc7f09
No related branches found
No related tags found
1 merge request
!168
fix authorization
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/audio/funkwhale/ffa/utils/Extensions.kt
+7
-1
7 additions, 1 deletion
app/src/main/java/audio/funkwhale/ffa/utils/Extensions.kt
app/src/main/java/audio/funkwhale/ffa/utils/OAuth.kt
+25
-12
25 additions, 12 deletions
app/src/main/java/audio/funkwhale/ffa/utils/OAuth.kt
with
32 additions
and
13 deletions
app/src/main/java/audio/funkwhale/ffa/utils/Extensions.kt
+
7
−
1
View file @
20ee27da
...
@@ -76,8 +76,13 @@ fun Request.authorize(context: Context, oAuth: OAuth): Request {
...
@@ -76,8 +76,13 @@ fun Request.authorize(context: Context, oAuth: OAuth): Request {
val
old
=
state
.
accessToken
val
old
=
state
.
accessToken
val
auth
=
ClientSecretPost
(
oAuth
.
state
().
clientSecret
)
val
auth
=
ClientSecretPost
(
oAuth
.
state
().
clientSecret
)
val
done
=
CompletableDeferred
<
Boolean
>()
val
done
=
CompletableDeferred
<
Boolean
>()
val
tokenService
=
oAuth
.
service
(
context
)
state
.
performActionWithFreshTokens
(
oAuth
.
service
(
context
),
auth
)
{
token
,
_
,
_
->
state
.
performActionWithFreshTokens
(
tokenService
,
auth
)
{
token
,
_
,
e
->
if
(
e
!=
null
)
{
Log
.
e
(
"Request.authorize()"
,
"performActionWithFreshToken failed: ${e}"
)
Log
.
e
(
"Request.authorize()"
,
Log
.
getStackTraceString
(
e
))
}
if
(
token
==
old
)
{
if
(
token
==
old
)
{
Log
.
i
(
"Request.authorize()"
,
"Accesstoken not renewed"
)
Log
.
i
(
"Request.authorize()"
,
"Accesstoken not renewed"
)
}
}
...
@@ -88,6 +93,7 @@ fun Request.authorize(context: Context, oAuth: OAuth): Request {
...
@@ -88,6 +93,7 @@ fun Request.authorize(context: Context, oAuth: OAuth): Request {
done
.
complete
(
true
)
done
.
complete
(
true
)
}
}
done
.
await
()
done
.
await
()
tokenService
.
dispose
()
return
@runBlocking
this
return
@runBlocking
this
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/audio/funkwhale/ffa/utils/OAuth.kt
+
25
−
12
View file @
20ee27da
...
@@ -98,8 +98,13 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory
...
@@ -98,8 +98,13 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory
return
if
(
state
.
refreshToken
!=
null
)
{
return
if
(
state
.
refreshToken
!=
null
)
{
val
refreshRequest
=
state
.
createTokenRefreshRequest
()
val
refreshRequest
=
state
.
createTokenRefreshRequest
()
val
auth
=
ClientSecretPost
(
state
.
clientSecret
)
val
auth
=
ClientSecretPost
(
state
.
clientSecret
)
val
refreshService
=
service
(
context
)
runBlocking
{
runBlocking
{
service
(
context
).
performTokenRequest
(
refreshRequest
,
auth
)
{
response
,
e
->
refreshService
.
performTokenRequest
(
refreshRequest
,
auth
)
{
response
,
e
->
if
(
e
!=
null
)
{
Log
.
e
(
"OAuth"
,
"performTokenRequest failed: ${e}"
)
Log
.
e
(
"OAuth"
,
Log
.
getStackTraceString
(
e
))
}
else
{
state
.
apply
{
state
.
apply
{
Log
.
i
(
"OAuth"
,
"applying new authState"
)
Log
.
i
(
"OAuth"
,
"applying new authState"
)
update
(
response
,
e
)
update
(
response
,
e
)
...
@@ -107,6 +112,8 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory
...
@@ -107,6 +112,8 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory
}
}
}
}
}
}
}
refreshService
.
dispose
()
true
true
}
else
{
}
else
{
false
false
...
@@ -202,17 +209,23 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory
...
@@ -202,17 +209,23 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory
AuthorizationResponse
.
fromIntent
(
authorization
)
?.
let
{
AuthorizationResponse
.
fromIntent
(
authorization
)
?.
let
{
val
auth
=
ClientSecretPost
(
state
().
clientSecret
)
val
auth
=
ClientSecretPost
(
state
().
clientSecret
)
val
requestService
=
service
(
context
)
service
(
context
).
performTokenRequest
(
it
.
createTokenExchangeRequest
(),
auth
)
{
response
,
e
->
requestService
.
performTokenRequest
(
it
.
createTokenExchangeRequest
(),
auth
)
{
response
,
e
->
state
if
(
e
!=
null
)
{
.
apply
{
Log
.
e
(
"FFA"
,
"performTokenRequest failed: ${e}"
)
Log
.
e
(
"FFA"
,
Log
.
getStackTraceString
(
e
))
}
else
{
state
.
apply
{
update
(
response
,
e
)
update
(
response
,
e
)
save
()
save
()
}
}
}
if
(
response
!=
null
)
success
()
if
(
response
!=
null
)
success
()
else
Log
.
e
(
"FFA"
,
"performTokenRequest() not successful"
)
else
Log
.
e
(
"FFA"
,
"performTokenRequest() not successful"
)
}
}
requestService
.
dispose
()
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment