mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 11:20:17 -04:00
Add redirect url to authentication process
This commit is contained in:
parent
1fbbf5904a
commit
567b8e0901
|
@ -12,6 +12,13 @@ function useCodeAndError() {
|
|||
return [code, error];
|
||||
}
|
||||
|
||||
function inferRedirectUrl() {
|
||||
// Strip query parameters
|
||||
const { protocol, host, pathname } = window.location;
|
||||
const redirectUrl = `${protocol}//${host}${pathname}`;
|
||||
return redirectUrl;
|
||||
}
|
||||
|
||||
export default function Authenticator() {
|
||||
const { provider } = useParams<{ provider: string }>();
|
||||
const [code, error] = useCodeAndError();
|
||||
|
@ -31,7 +38,7 @@ export default function Authenticator() {
|
|||
useEffect(() => {
|
||||
if (code) {
|
||||
setPending(true);
|
||||
createSession(code)
|
||||
createSession(code, inferRedirectUrl())
|
||||
.then(({ token }) => {
|
||||
setToken(token ?? null);
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export async function createSession(code: string) {
|
||||
export async function createSession(code: string, redirectUrl: string) {
|
||||
const res = await fetch('http://localhost:5000/create_session', {
|
||||
method: 'post',
|
||||
body: JSON.stringify({ code }),
|
||||
body: JSON.stringify({ code, redirectUrl }),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ICarpool, IUser } from './types';
|
||||
import { ICarpool } from './types';
|
||||
import UISecondaryBox from './UISecondaryBox';
|
||||
|
||||
function MemberList({ members }: { members: IUser[] }) {
|
||||
function MemberList({ members }: { members: ICarpool['members'] }) {
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
||||
{members.length > 0
|
||||
|
|
|
@ -29,7 +29,10 @@ export type ICarpool = {
|
|||
description: string;
|
||||
eventId: number | null;
|
||||
event?: IEvent;
|
||||
members: IUser[];
|
||||
members: {
|
||||
id: number;
|
||||
name: string;
|
||||
}[];
|
||||
invitations: IInvitation[];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user