Skip to content

Commit

Permalink
wip: Allow to provide access to the site using a referrer policy #11
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Jul 3, 2024
1 parent db18bcc commit cbaadca
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions layouts/KeycloakLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@ const hasAccess = ref(false)
// Functions
function passReferrer () {
console.log(document.referrer)
if (!document.referrer) return false
let domains = _.get(theme.value, 'referrer.domains', [])
if (!Arrays.isArray(domains)) domains = _.split(domains, ',')
let hasAccess = false
console.log(domaines)
let pass = false
_.forEach(domains, domain => {
if (document.referrer.contains(domain)) {
hasAccess = true
pass = true
return false
}
})
return hasAccess
console.log(pass)
return pass
}
function passKeycloak () {
const keycloak = new Keycloak(theme.value.keycloak)
Expand All @@ -58,6 +61,7 @@ onMounted(() => {
hasAccess.value = passReferrer()
}
if (!hasAccess.value) {
console.log('pass keycloak')
if (useKeycloak) {
hasAccess.value = passKeycloak()
} else {
Expand Down

0 comments on commit cbaadca

Please sign in to comment.