Skip to content

Commit

Permalink
Change accessprompt flow to use client identifier instead of urls
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardsph committed Aug 8, 2024
1 parent fae7f54 commit d33149d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions api/accessPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ export const getAccessPromptResource = async (

export const requestAccessPrompt = async (params: {
resource: string;
accessPromptUrl: string;
client: string;
}): Promise<void> => {
await makeApiRequest<AccessRequest[]>(
"accessprompt",
"POST",
JSON.stringify({
resource: params.resource,
accessPromptUrl: params.accessPromptUrl,
client: params.client,
})
);
};
6 changes: 3 additions & 3 deletions app/access-prompt/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ import CardInfo from "@/components/common/CardInfo";
import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome";

const Page: React.FC = () => {
const { webId, type, accessPromptUrl } = useLocalSearchParams();
const { webId, client, type } = useLocalSearchParams();
const router = useRouter();
const { data } = useQuery<AccessPromptResource>({
queryKey: ["accessPromptResource"],
queryFn: () =>
getAccessPromptResource({
type: type as string,
client: client as string,
webId: webId as string,
accessPromptUrl: accessPromptUrl as string,
}),
});
const navigation = useNavigation();
Expand Down Expand Up @@ -75,7 +75,7 @@ const Page: React.FC = () => {
if (!data) return;
mutation.mutate({
resource: data.resource,
accessPromptUrl: accessPromptUrl as string,
client: client as string,
});
router.replace({
pathname: "/access-prompt/confirmed",
Expand Down
8 changes: 2 additions & 6 deletions app/scan-qr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ export default function Logout() {
setScanned(true);
try {
const resourceInfo = JSON.parse(data);
if (
resourceInfo.webId &&
resourceInfo.accessPromptUrl &&
resourceInfo.type
) {
if (resourceInfo.webId && resourceInfo.client && resourceInfo.type) {
replace({
pathname: "/access-prompt",
params: {
webId: resourceInfo.webId,
accessPromptUrl: resourceInfo.accessPromptUrl,
client: resourceInfo.client,
type: resourceInfo.type,
},
});
Expand Down
3 changes: 1 addition & 2 deletions types/accessPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
//
export interface AccessPromptQR {
webId: string;
accessPromptUrl: string;
client: string;
type: string;
}

export interface AccessPromptResource {
webId: string;
accessPromptUrl: string;
resource: string;
resourceName: string;
logo: string;
Expand Down

0 comments on commit d33149d

Please sign in to comment.