Skip to content

Commit 2c9252d

Browse files
justserdarautofix-ci[bot]atinux
authored
feat: added linkedIn auth provider (#13)
* feat: added linkedIn auth provider * refactor: added env vars, cleanup and adapted discord url parser Retested the code and have working auth in browser. * update: bumped up to latest version with changes * [autofix.ci] apply automated fixes * chore: update --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Sébastien Chopin <[email protected]>
1 parent 36cadda commit 2c9252d

File tree

8 files changed

+1009
-2411
lines changed

8 files changed

+1009
-2411
lines changed

playground/.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ NUXT_OAUTH_DISCORD_CLIENT_ID=
2424
NUXT_OAUTH_DISCORD_CLIENT_SECRET=
2525
# Battle.net OAuth
2626
NUXT_OAUTH_BATTLEDOTNET_CLIENT_ID=
27-
NUXT_OAUTH_BATTLEDOTNET_CLIENT_SECRET=
27+
NUXT_OAUTH_BATTLEDOTNET_CLIENT_SECRET=
28+
# LinkedIn
29+
NUXT_OAUTH_LINKEDIN_CLIENT_ID=
30+
NUXT_OAUTH_LINKEDIN_CLIENT_SECRET=

playground/app.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ const providers = computed(() => [
4949
to: '/auth/microsoft',
5050
disabled: Boolean(user.value?.microsoft),
5151
icon: 'i-simple-icons-microsoft',
52+
},
53+
{
54+
label: user.value?.linkedin?.email || 'LinkedIn',
55+
to: '/auth/linkedin',
56+
disabled: Boolean(user.value?.linkedin),
57+
icon: 'i-simple-icons-linkedin',
5258
}
5359
5460
].map(p => ({

playground/auth.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ declare module '#auth-utils' {
99
microsoft?: any;
1010
discord?: any
1111
battledotnet?: any
12+
linkedin?: any
1213
}
1314
loggedInAt: number
1415
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default oauth.linkedinEventHandler({
2+
config: {
3+
emailRequired: true
4+
},
5+
async onSuccess(event, { user }) {
6+
await setUserSession(event, {
7+
user: {
8+
linkedin: user,
9+
},
10+
loggedInAt: Date.now()
11+
})
12+
13+
return sendRedirect(event, '/')
14+
}
15+
})

0 commit comments

Comments
 (0)