Skip to content

Commit 3ee7c43

Browse files
committed
Added community site redirection
1 parent 659b114 commit 3ee7c43

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/common/utils.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,13 +1031,29 @@ export const isV2URL = url => {
10311031
return false
10321032
}
10331033

1034+
export const isCommunitySiteURL = url => {
1035+
if(!url)
1036+
return false
1037+
if(url.startsWith('https://openconceptlab.org'))
1038+
return true
1039+
if(url.startsWith('http://localhost:4006'))
1040+
return true
1041+
if(!url.includes('.openconceptlab.org'))
1042+
return false
1043+
if(url.startsWith('https://preview.'))
1044+
return true
1045+
return false
1046+
}
1047+
1048+
export const isOtherOCLClientURL = referrer => referrer && (isV3URL(referrer) || isV2URL(referrer) || isCommunitySiteURL(referrer))
1049+
10341050
export const isRedirectingToLoginViaReferrer = location => {
10351051
const { search, hash } = location
10361052
const queryParams = new URLSearchParams(search)
10371053
const referrer = queryParams.get('referrer')
10381054
const parts = hash.split('?')
10391055
let params = new URLSearchParams(parts[1])
1040-
return referrer && (isV3URL(referrer) || isV2URL(referrer)) && params.get('auth') === 'true'
1056+
return isOtherOCLClientURL(referrer) && params.get('auth') === 'true'
10411057
}
10421058

10431059
export const toCamelCase = str => {

src/components/app/App.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React from 'react';
33
import { Route, Switch, withRouter } from 'react-router-dom';
44
import {
5-
recordGAPageView, isLoggedIn, getLoginURL, isV3URL, isV2URL, isRedirectingToLoginViaReferrer,
5+
recordGAPageView, isLoggedIn, getLoginURL, isOtherOCLClientURL, isRedirectingToLoginViaReferrer,
66
isInWaitlist, getEnv
77
} from '../../common/utils';
88
import Error404 from '../errors/Error404';
@@ -91,7 +91,7 @@ const App = props => {
9191
const referrer = queryParams.get('referrer')
9292
if(isLoggedIn()) {
9393
window.location.hash = '#' + pathname
94-
} else if(referrer && (isV3URL(referrer) || isV2URL(referrer)) && !isLoggedIn()) {
94+
} else if(isOtherOCLClientURL(referrer) && !isLoggedIn()) {
9595
const parts = hash.split('?')
9696
let params = new URLSearchParams(parts[1])
9797
if(params.get('auth') === 'true') {

0 commit comments

Comments
 (0)