Skip to content

Commit

Permalink
feat: add redirect uri to consent page
Browse files Browse the repository at this point in the history
  • Loading branch information
its-felix committed Jan 13, 2024
1 parent 0b69b2c commit ff0f501
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib/api/api.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export interface OAuth2ConsentInfo {
apiTokensWithInsufficientPermissions: ReadonlyArray<MinimalApiToken>;
previouslyConsentedGw2AccountIds: ReadonlyArray<string>;
containsAnyGw2AccountRelatedScopes: boolean;
redirectUri: string;
}

export interface MinimalApiToken {
Expand Down
16 changes: 15 additions & 1 deletion src/pages/oauth2-consent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Header,
Multiselect,
MultiselectProps, SpaceBetween,
Spinner,
Spinner, TextContent,
} from '@cloudscape-design/components';
import React, {
useCallback, useEffect, useMemo, useState,
Expand Down Expand Up @@ -137,6 +137,13 @@ function ConsentForm({ consentInfo, setActiveWindow }: { consentInfo: OAuth2Cons
];
}, [selectedOptions]);

const redirectBase = useMemo(() => {
const url = new URL(consentInfo.redirectUri);
url.search = '';
url.pathname = '';
return url.toString();
}, [consentInfo]);

return (
<>
<Container header={<Header variant={'h1'}>Authorize {consentInfo.clientRegistration.displayName}</Header>} variant={'stacked'}>
Expand Down Expand Up @@ -181,6 +188,13 @@ function ConsentForm({ consentInfo, setActiveWindow }: { consentInfo: OAuth2Cons
</Form>
</form>
</Container>
<Container variant={'stacked'} disableContentPaddings={true}>
<TextContent>
<Box textAlign={'center'} padding={'xs'}>
<small>You will be redirected to <b>{redirectBase}</b></small>
</Box>
</TextContent>
</Container>
</>
);
}
Expand Down

0 comments on commit ff0f501

Please sign in to comment.