-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(console|passport): Delete group, delete member and identity of g…
…roup member (#2597)
- Loading branch information
1 parent
d0da01e
commit ace4ca9
Showing
12 changed files
with
742 additions
and
58 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
59 changes: 59 additions & 0 deletions
59
apps/console/app/routes/__layout/spuorg/$groupID/delete.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,59 @@ | ||
import { generateTraceContextHeaders } from '@proofzero/platform-middleware/trace' | ||
import { getRollupReqFunctionErrorWrapper } from '@proofzero/utils/errors' | ||
import { ActionFunction, redirect } from '@remix-run/cloudflare' | ||
import { commitFlashSession, requireJWT } from '~/utilities/session.server' | ||
import createCoreClient from '@proofzero/platform-clients/core' | ||
import { getAuthzHeaderConditionallyFromToken } from '@proofzero/utils' | ||
import { | ||
IdentityGroupURN, | ||
IdentityGroupURNSpace, | ||
} from '@proofzero/urns/identity-group' | ||
import { appendToastToFlashSession } from '~/utils/toast.server' | ||
import { ToastType } from '@proofzero/design-system/src/atoms/toast' | ||
|
||
export const action: ActionFunction = getRollupReqFunctionErrorWrapper( | ||
async ({ request, context, params }) => { | ||
const groupID = params.groupID as string | ||
const groupURN = IdentityGroupURNSpace.urn( | ||
groupID as string | ||
) as IdentityGroupURN | ||
|
||
const jwt = await requireJWT(request, context.env) | ||
const traceHeader = generateTraceContextHeaders(context.traceSpan) | ||
|
||
const coreClient = createCoreClient(context.env.Core, { | ||
...getAuthzHeaderConditionallyFromToken(jwt), | ||
...traceHeader, | ||
}) | ||
|
||
let toastSession | ||
|
||
try { | ||
await coreClient.account.deleteIdentityGroup.mutate(groupURN) | ||
|
||
toastSession = await appendToastToFlashSession( | ||
request, | ||
{ | ||
message: `Succesfully deleted group`, | ||
type: ToastType.Success, | ||
}, | ||
context.env | ||
) | ||
} catch (e) { | ||
toastSession = await appendToastToFlashSession( | ||
request, | ||
{ | ||
message: `There was an error deleting the group`, | ||
type: ToastType.Error, | ||
}, | ||
context.env | ||
) | ||
} | ||
|
||
return redirect('/spuorg', { | ||
headers: { | ||
'Set-Cookie': await commitFlashSession(toastSession, context.env), | ||
}, | ||
}) | ||
} | ||
) |
Oops, something went wrong.