Skip to content

Commit

Permalink
chore: add redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
sztok7 committed May 26, 2024
1 parent dbc550c commit 5fa379c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/zu-git-pass-client/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
REACT_APP_ZU_GIT_SERVER_API=https://api.zugitproof.berlin.chainsafe.dev
REACT_APP_GITHUB_CLIENT_ID=Ov23liXuY3hXVMFNHo5X
REACT_APP_DISCOURSE_URL=http://localhost:4200/auth/oauth2_basic/callback
3 changes: 2 additions & 1 deletion packages/zu-git-pass-client/src/GitHubCallback.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect } from 'react';
import { redirect } from 'react-router-dom';

export default function GitHubCallback() {

Expand All @@ -15,7 +16,7 @@ export default function GitHubCallback() {
})
.then(response => response.json())
.then(data => {
// close popup
redirect('/')
});
}
}, []);
Expand Down
16 changes: 6 additions & 10 deletions packages/zu-git-pass-client/src/ZupassLogin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useCallback } from 'react';
import { getWithoutProvingUrl } from '@pcd/passport-interface/PassportInterface';
import { zupassPopupExecute } from '@pcd/passport-interface';
import { MessagePCDPackage } from '@pcd/message-pcd'

const constructProofUrl = () => {
return getWithoutProvingUrl('https://zupass.org', window.location.href, 'message-pcd', true)
Expand All @@ -13,16 +12,13 @@ export default function ZupassLogin() {

const result = await zupassPopupExecute(proofUrl)


if (result.type !== 'pcd') return

console.log(result.pcdStr)

const pcd = MessagePCDPackage.deserialize(result.pcdStr)
//const pcd = MessagePCDPackage.deserialize(result.pcdStr)

console.log(pcd)
const discourseUrl = process.env.REACT_APP_DISCOURSE_URL // searchParams.get('discourse_url')

const discourseUrl = process.env.DISCOURSE_URL // searchParams.get('discourse_url')
window.location.href = discourseUrl

try {
const response = await fetch(discourseUrl, {
Expand All @@ -39,15 +35,15 @@ export default function ZupassLogin() {

const result = await response.json();
console.log("Success:", result);

window.location.href = discourseUrl
} catch (error) {
console.error("Error:", error);
}
}, []);


return (
<>
<button onClick={login}>Mit Zupass anmelden</button>
</>
<button onClick={login} className='btn-github'>Mit Zupass anmelden</button>
);
}

0 comments on commit 5fa379c

Please sign in to comment.