Skip to content

Commit 81bbac2

Browse files
committed
attach token with projectsMETA request
1 parent 4e1fe89 commit 81bbac2

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/lib/project-fetcher-hoc.jsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const fetchProjectToken = async projectId => {
4040
searchParams.delete('token');
4141
const newUrl = `${location.pathname}${searchParams.toString() ? '?' + searchParams.toString() : ''}${location.hash}`;
4242
window.history.replaceState({}, document.title, newUrl);
43+
storage.setProjectToken(token);
4344
return token;
4445
}
4546
// Parse #1?token=abcdef
@@ -51,6 +52,7 @@ const fetchProjectToken = async projectId => {
5152
const newHash = hashParams.toString() ? `?${hashParams.toString()}` : '';
5253
const newUrl = `${location.pathname}${location.search}${location.hash.split('?')[0]}${newHash}`;
5354
window.history.replaceState({}, document.title, newUrl);
55+
storage.setProjectToken(token);
5456
return token;
5557
}
5658
try {

‎src/lib/tw-project-meta-fetcher-hoc.jsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ const {API_HOST} = require('./brand');
99
import {setProjectTitle} from '../reducers/project-title';
1010
import {setAuthor, setDescription,setUsername} from '../reducers/tw';
1111

12+
import storage from './storage';
13+
1214
export const fetchProjectMeta = async projectId => {
1315
const urls = [
14-
API_HOST+`/projectsMETA?id=${projectId}`,
15-
API_HOST+`/projectsMETA?id=${projectId}`
16+
API_HOST+`/projectsMETA?id=${projectId}&token=${storage.getProjectToken()}`,
17+
API_HOST+`/projectsMETA?id=${projectId}&token=${storage.getProjectToken()}`
1618
];
1719
let firstError;
1820
for (const url of urls) {

0 commit comments

Comments
 (0)