-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(passport): Settings - applications layout (#1971)
- Loading branch information
Showing
11 changed files
with
529 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
apps/passport/app/routes/settings/applications/$clientId/revoke.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
}, | ||
}) | ||
} |
27 changes: 27 additions & 0 deletions
27
apps/passport/app/routes/settings/applications/$clientId/scopes.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.