-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add admin impersonation feature in dev
This gives devs the ability to impersonate users to reproduce reported bugs
- Loading branch information
1 parent
8a5b24b
commit d726269
Showing
2 changed files
with
32 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { getSelfPerson } from '@/app/utils/airtable' | ||
import { redirect } from 'next/navigation' | ||
import { NextRequest } from 'next/server' | ||
|
||
import { HsSession, signAndSet } from '@/app/utils/auth' | ||
|
||
export async function GET( | ||
_request: NextRequest, | ||
{ params }: { params: { slackId: string } }, | ||
) { | ||
if (process.env.NODE_ENV === 'development') { | ||
// only allow impersonation in development while testing | ||
const { slackId } = params | ||
// look for airtable user with this record | ||
const person = await getSelfPerson(slackId) | ||
const id = person.id | ||
const email = person.fields.email | ||
|
||
const session: HsSession = { | ||
personId: id, | ||
authType: 'impersonation', | ||
slackId, | ||
email, | ||
} | ||
|
||
await signAndSet(session) | ||
} | ||
|
||
redirect('/signpost') | ||
} |
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