Skip to content

Commit f0551b0

Browse files
feat(providers): refactor Slack provider (#2848)
* chore(dev): add SlackProvider to dev app * feat(providers): refactor Slack provider * chore(dev): remove unwanted provider
1 parent c2fd58d commit f0551b0

File tree

3 files changed

+59
-25
lines changed

3 files changed

+59
-25
lines changed

app/pages/api/auth/[...nextauth].ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import DiscordProvider from "next-auth/providers/discord"
2020
import AzureADProvider from "next-auth/providers/azure-ad"
2121
import SpotifyProvider from "next-auth/providers/spotify"
2222
import CognitoProvider from "next-auth/providers/cognito"
23+
import SlackProvider from "next-auth/providers/slack"
2324

2425
// import { PrismaAdapter } from "@next-auth/prisma-adapter"
2526
// import { PrismaClient } from "@prisma/client"
@@ -149,6 +150,10 @@ export default NextAuth({
149150
clientSecret: process.env.COGNITO_SECRET,
150151
issuer: process.env.COGNITO_ISSUER,
151152
}),
153+
SlackProvider({
154+
clientId: process.env.SLACK_ID,
155+
clientSecret: process.env.SLACK_SECRET,
156+
}),
152157
],
153158
jwt: {
154159
encryption: true,

src/providers/slack.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/providers/slack.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { OAuthConfig, OAuthUserConfig } from "."
2+
3+
export interface SlackProfile {
4+
ok: boolean
5+
sub: string
6+
"https://slack.com/user_id": string
7+
"https://slack.com/team_id": string
8+
email: string
9+
email_verified: boolean
10+
date_email_verified: number
11+
name: string
12+
picture: string
13+
given_name: string
14+
family_name: string
15+
locale: string
16+
"https://slack.com/team_name": string
17+
"https://slack.com/team_domain": string
18+
"https://slack.com/user_image_24": string
19+
"https://slack.com/user_image_32": string
20+
"https://slack.com/user_image_48": string
21+
"https://slack.com/user_image_72": string
22+
"https://slack.com/user_image_192": string
23+
"https://slack.com/user_image_512": string
24+
"https://slack.com/user_image_1024": string
25+
"https://slack.com/team_image_34": string
26+
"https://slack.com/team_image_44": string
27+
"https://slack.com/team_image_68": string
28+
"https://slack.com/team_image_88": string
29+
"https://slack.com/team_image_102": string
30+
"https://slack.com/team_image_132": string
31+
"https://slack.com/team_image_230": string
32+
"https://slack.com/team_image_default": boolean
33+
}
34+
35+
export default function Slack<P extends Record<string, any> = SlackProfile>(
36+
options: OAuthUserConfig<P>
37+
): OAuthConfig<P> {
38+
return {
39+
id: "slack",
40+
name: "Slack",
41+
type: "oauth",
42+
wellKnown: "https://slack.com/.well-known/openid-configuration",
43+
authorization: { params: { scope: "openid profile email" } },
44+
profile(profile) {
45+
return {
46+
id: profile.sub,
47+
name: profile.name,
48+
email: profile.email,
49+
image: profile.picture,
50+
}
51+
},
52+
options,
53+
}
54+
}

0 commit comments

Comments
 (0)