Add additional logs to token verification (#279)

This commit is contained in:
Brahim Hadriche authored and GitHub committed 2024-02-02 20:23:06 -05:00
1 parent 80d3d24e39
commit 85e30c8b22
1 file changed
+9 -1
@@ -505,14 +505,22 @@ We apologize for the inconvenience.`
function VerifyTokenScope(token as string) as boolean
tokenObject = ParseJson(token)
if tokenObject = invalid
LogWarn("Failed to json parse token:", token)
return false
end if
if not IsArray(tokenObject.scopes)
LogWarn("Token scopes are not an array:", tokenObject.scopes)
return false
end if
scopes = tokenObject.scopes.join(",")
return scopes = Invidious.AUTH_SCOPES
expectedScopes = Invidious.AUTH_SCOPES
validScopes = expectedScopes = scopes
if not validScopes
LogWarn(`Token scopes do not match expected scopes. Expected: "${expectedScopes}", got: "${scopes}"`)
end if
return validScopes
end function
function DeleteAuthToken()