-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(signin): ♿️ Add SSO signin for Sleekplan
- Loading branch information
1 parent
0710403
commit 57663fd
Showing
4 changed files
with
50 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { withSentry } from '@sentry/nextjs' | ||
import { User } from 'db' | ||
import { sign } from 'jsonwebtoken' | ||
import { NextApiRequest, NextApiResponse } from 'next' | ||
import { getAuthenticatedUser } from 'services/api/utils' | ||
import { methodNotAllowed, notAuthenticated } from 'utils' | ||
|
||
const handler = async (req: NextApiRequest, res: NextApiResponse) => { | ||
if (req.method === 'GET') { | ||
const user = await getAuthenticatedUser(req) | ||
if (!user) return notAuthenticated(res) | ||
const ssoToken = createSSOToken(user) | ||
res.redirect(`https://feedback.typebot.io?sso=${ssoToken}`) | ||
return | ||
} | ||
methodNotAllowed(res) | ||
} | ||
|
||
const createSSOToken = (user: User) => { | ||
if (!process.env.SLEEKPLAN_SSO_KEY) return | ||
const userData = { | ||
mail: user.email, | ||
id: user.id, | ||
name: user.name, | ||
img: user.image, | ||
} | ||
|
||
return sign(userData, process.env.SLEEKPLAN_SSO_KEY, { algorithm: 'HS256' }) | ||
} | ||
|
||
export default withSentry(handler) |
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
57663fd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
builder-v2 – ./apps/builder
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app
57663fd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
viewer-v2 – ./apps/viewer
bot.matthesv.de
bot.contakit.com
demo.wemakebots.xyz
chat.hayuri.id
viewer.typebot.io
app.yvon.earth
chat.matthesv.de
88584434.therpm.club
zap.fundviser.in
92109660.therpm.club
bot.digitalpointer.id
criar.somaperuzzo.com
link.venturasuceder.com
invite.bridesquadapp.com
chat.thehomebuyersusa.com
bot.outstandbrand.com
typebot-viewer.vercel.app
bot.pratikmandalia.com
bot.adventureconsulting.hu
chat.atlasoutfittersk9.com
bot.pinpointinteractive.com
tarian.theiofoundation.org
viewer-v2-typebot-io.vercel.app
viewer-v2-git-main-typebot-io.vercel.app