Skip to content

Commit 0f8525a

Browse files
committed
OpenConceptLab/ocl_issues#2219 | can exchange with v2
1 parent b603a8b commit 0f8525a

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/common/utils.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,11 +1027,23 @@ export const isV3URL = url => {
10271027
return false
10281028
}
10291029

1030+
export const isV2URL = url => {
1031+
if(!url)
1032+
return false
1033+
if(url.startsWith('http://localhost:4000'))
1034+
return true
1035+
if(!url.includes('.openconceptlab.org'))
1036+
return false
1037+
if(url.startsWith('https://app.'))
1038+
return true
1039+
return false
1040+
}
1041+
10301042
export const isRedirectingToLoginViaReferrer = location => {
10311043
const { search, hash } = location
10321044
const queryParams = new URLSearchParams(search)
10331045
const referrer = queryParams.get('referrer')
10341046
const parts = hash.split('?')
10351047
let params = new URLSearchParams(parts[1])
1036-
return referrer && isV3URL(referrer) && params.get('auth') === 'true'
1048+
return referrer && (isV3URL(referrer) || isV2URL(referrer)) && params.get('auth') === 'true'
10371049
}

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, isRedirectingToLoginViaReferrer
5+
recordGAPageView, isLoggedIn, getLoginURL, isV3URL, isV2URL, isRedirectingToLoginViaReferrer
66
} from '../../common/utils';
77
import Error404 from '../errors/Error404';
88
import Error403 from '../errors/Error403';
@@ -70,7 +70,7 @@ const App = props => {
7070
const referrer = queryParams.get('referrer')
7171
if(isLoggedIn()) {
7272
window.location.hash = '#' + pathname
73-
} else if(referrer && isV3URL(referrer) && !isLoggedIn()) {
73+
} else if(referrer && (isV3URL(referrer) || isV2URL(referrer)) && !isLoggedIn()) {
7474
const parts = hash.split('?')
7575
let params = new URLSearchParams(parts[1])
7676
if(params.get('auth') === 'true') {

0 commit comments

Comments
 (0)