fix(auth): both array and Im.List scopes can be added to redirectURL (#6416)

This commit is contained in:
dalbrx-forcam
2020-09-22 19:47:37 +02:00
committed by GitHub
parent 6b12f1507a
commit 95fd3e71ab
2 changed files with 39 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
import win from "core/window"
import Im from "immutable"
import { btoa, sanitizeUrl, generateCodeVerifier, createCodeChallenge } from "core/utils"
export default function authorize ( { auth, authActions, errActions, configs, authConfigs={} } ) {
@@ -52,10 +53,17 @@ export default function authorize ( { auth, authActions, errActions, configs, au
}
query.push("redirect_uri=" + encodeURIComponent(redirectUrl))
if (Array.isArray(scopes) && 0 < scopes.length) {
let scopesArray = []
if (Array.isArray(scopes)) {
scopesArray = scopes
} else if (Im.List.isList(scopes)) {
scopesArray = scopes.toArray()
}
if (scopesArray.length > 0) {
let scopeSeparator = authConfigs.scopeSeparator || " "
query.push("scope=" + encodeURIComponent(scopes.join(scopeSeparator)))
query.push("scope=" + encodeURIComponent(scopesArray.join(scopeSeparator)))
}
let state = btoa(new Date())