Skip to content

Commit

Permalink
feat: added linkedIn auth provider (#13)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Dec 7, 2023
1 parent 36cadda commit 2c9252d
Show file tree
Hide file tree
Showing 8 changed files with 1,009 additions and 2,411 deletions.
5 changes: 4 additions & 1 deletion playground/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ NUXT_OAUTH_DISCORD_CLIENT_ID=
NUXT_OAUTH_DISCORD_CLIENT_SECRET=
# Battle.net OAuth
NUXT_OAUTH_BATTLEDOTNET_CLIENT_ID=
NUXT_OAUTH_BATTLEDOTNET_CLIENT_SECRET=
NUXT_OAUTH_BATTLEDOTNET_CLIENT_SECRET=
# LinkedIn
NUXT_OAUTH_LINKEDIN_CLIENT_ID=
NUXT_OAUTH_LINKEDIN_CLIENT_SECRET=
6 changes: 6 additions & 0 deletions playground/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ const providers = computed(() => [
to: '/auth/microsoft',
disabled: Boolean(user.value?.microsoft),
icon: 'i-simple-icons-microsoft',
},
{
label: user.value?.linkedin?.email || 'LinkedIn',
to: '/auth/linkedin',
disabled: Boolean(user.value?.linkedin),
icon: 'i-simple-icons-linkedin',
}
].map(p => ({
Expand Down
1 change: 1 addition & 0 deletions playground/auth.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare module '#auth-utils' {
microsoft?: any;
discord?: any
battledotnet?: any
linkedin?: any
}
loggedInAt: number
}
Expand Down
15 changes: 15 additions & 0 deletions playground/server/routes/auth/linkedin.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default oauth.linkedinEventHandler({
config: {
emailRequired: true
},
async onSuccess(event, { user }) {
await setUserSession(event, {
user: {
linkedin: user,
},
loggedInAt: Date.now()
})

return sendRedirect(event, '/')
}
})
Loading

0 comments on commit 2c9252d

Please sign in to comment.