Skip to content

Commit

Permalink
feat(passport): Settings - applications layout (#1971)
Browse files Browse the repository at this point in the history
  • Loading branch information
poolsar42 authored Mar 27, 2023
1 parent 69a24fa commit 54963e6
Show file tree
Hide file tree
Showing 11 changed files with 529 additions and 71 deletions.
5 changes: 4 additions & 1 deletion apps/console/app/routes/apps/$clientId/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ export default function AppDetailIndexPage() {
</div>
}
>
<Await resolve={edgesResult} errorElement={<NestedErrorPage />}>
<Await
resolve={edgesResult}
errorElement={<NestedErrorPage text={'Data Loading Error'} />}
>
{(edgesResult) => {
return (
<LoginsPanel
Expand Down
5 changes: 4 additions & 1 deletion apps/console/app/routes/apps/$clientId/users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ rounded-lg border shadow"
</div>
}
>
<Await resolve={edgesResult} errorElement={<NestedErrorPage />}>
<Await
resolve={edgesResult}
errorElement={<NestedErrorPage text={'Data Loading Error'} />}
>
{(edgesResult) => {
if (!edgesResult.metadata.offset) {
edgesResult.metadata.offset = 0
Expand Down
2 changes: 1 addition & 1 deletion apps/passport/app/components/SideMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const navigation = {
name: 'Applications',
href: '/settings/applications',
icon: TbApps,
exists: false,
exists: true,
},
],
advanced: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { ActionFunction } from '@remix-run/cloudflare'
import { redirect } from '@remix-run/cloudflare'
import { getValidatedSessionContext } from '~/session.server'

import { getAccessClient } from '~/platform.server'

import { getFlashSession, commitFlashSession } from '~/session.server'
import { BadRequestError } from '@proofzero/errors'

export const action: ActionFunction = async ({ request, params, context }) => {
const session = await getFlashSession(request, context.env)

const { jwt } = await getValidatedSessionContext(
request,
context.consoleParams,
context.env,
context.traceSpan
)

const { clientId } = params

if (!clientId) {
throw new BadRequestError({ message: 'Client ID is required for query' })
}

try {
const accessClient = getAccessClient(context.env, context.traceSpan, jwt)

await accessClient.revokeAppAuthorization.mutate({ clientId })

session.flash(
'tooltipMessage',
JSON.stringify({
type: 'success',
message: 'Access Removed',
})
)
} catch (ex) {
console.error(ex)

session.flash(
'tooltipMessage',
JSON.stringify({
type: 'error',
message: 'Error Removing Access',
})
)
}

return redirect('/settings/applications', {
headers: {
'Set-Cookie': await commitFlashSession(context.env, session),
},
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { LoaderFunction } from '@remix-run/cloudflare'
import { getValidatedSessionContext } from '~/session.server'
import { getAccessClient } from '~/platform.server'
import { BadRequestError } from '@proofzero/errors'

export const loader: LoaderFunction = async ({ request, params, context }) => {
const { accountUrn } = await getValidatedSessionContext(
request,
context.consoleParams,
context.env,
context.traceSpan
)
const { clientId } = params

if (!clientId) {
throw new BadRequestError({ message: 'Client ID is required for query' })
}

const accessClient = getAccessClient(context.env, context.traceSpan)

const scopes = await accessClient.getAuthorizedAppScopes.query({
clientId,
accountURN: accountUrn,
})

return scopes
}
Loading

0 comments on commit 54963e6

Please sign in to comment.