mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-16 00:50:18 -04:00
make authorization endpoint's redirect url react to window location
This commit is contained in:
parent
14c4ded29e
commit
62633aed17
2
.env
2
.env
|
@ -1,2 +1,2 @@
|
||||||
REACT_APP_API_ENDPOINT_0=http://localhost:5000/api
|
REACT_APP_API_DOMAIN_=http://localhost:5000/
|
||||||
REACT_APP_API_DOMAIN=https://wheelshare-altbackend-2efyw.ondigitalocean.app/
|
REACT_APP_API_DOMAIN=https://wheelshare-altbackend-2efyw.ondigitalocean.app/
|
||||||
|
|
15
src/components/Authentication/authorizationEndpoint.ts
Normal file
15
src/components/Authentication/authorizationEndpoint.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
function createAuthorizationEndpoint(redirectUrl: string) {
|
||||||
|
const url = new URL('https://ion.tjhsst.edu/oauth/authorize');
|
||||||
|
|
||||||
|
url.searchParams.set('response_type', 'code');
|
||||||
|
url.searchParams.set('client_id', 'rNa6n9YSg8ftINdyVPpUsaMuxNbHLo9dh1OsOktR');
|
||||||
|
url.searchParams.set('redirect_uri', redirectUrl);
|
||||||
|
url.searchParams.set('scope', 'read');
|
||||||
|
|
||||||
|
return url.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
const redirectUrl = `${window.location.protocol}://${window.location.host}/auth/ion/callback`;
|
||||||
|
const authorizationEndpoint = createAuthorizationEndpoint(redirectUrl);
|
||||||
|
|
||||||
|
export default authorizationEndpoint;
|
|
@ -1,30 +1,13 @@
|
||||||
|
import authorizationEndpoint from './Authentication/authorizationEndpoint';
|
||||||
import UILink from './UILink';
|
import UILink from './UILink';
|
||||||
import UIPrimaryTitle from './UIPrimaryTitle';
|
import UIPrimaryTitle from './UIPrimaryTitle';
|
||||||
|
|
||||||
function createAuthorizationEndpoint(redirectUrl: string) {
|
|
||||||
const url = new URL('https://ion.tjhsst.edu/oauth/authorize');
|
|
||||||
|
|
||||||
url.searchParams.set('response_type', 'code');
|
|
||||||
url.searchParams.set('client_id', 'rNa6n9YSg8ftINdyVPpUsaMuxNbHLo9dh1OsOktR');
|
|
||||||
url.searchParams.set('redirect_uri', redirectUrl);
|
|
||||||
url.searchParams.set('scope', 'read');
|
|
||||||
|
|
||||||
return url.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
const dev = true;
|
|
||||||
const endpoint = createAuthorizationEndpoint(
|
|
||||||
dev
|
|
||||||
? 'http://localhost:3000/auth/ion/callback'
|
|
||||||
: 'https://wheelshare.space/auth/ion/callback'
|
|
||||||
);
|
|
||||||
|
|
||||||
export default function WheelShareLoggedOut() {
|
export default function WheelShareLoggedOut() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UIPrimaryTitle>WheelShare</UIPrimaryTitle>
|
<UIPrimaryTitle>WheelShare</UIPrimaryTitle>
|
||||||
<p>To get started, log in with your Ion account.</p>
|
<p>To get started, log in with your Ion account.</p>
|
||||||
<UILink href={endpoint}>Log in</UILink>
|
<UILink href={authorizationEndpoint}>Log in</UILink>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user