Skip to content

Commit

Permalink
Add Line-Provider Playground
Browse files Browse the repository at this point in the history
  • Loading branch information
renogies committed Dec 26, 2024
1 parent 4c606b6 commit 0f5e240
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
6 changes: 5 additions & 1 deletion playground/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,8 @@ NUXT_OAUTH_STRAVA_CLIENT_SECRET=
# Hubspot
NUXT_OAUTH_HUBSPOT_CLIENT_ID=
NUXT_OAUTH_HUBSPOT_CLIENT_SECRET=
NUXT_OAUTH_HUBSPOT_REDIRECT_URL=
NUXT_OAUTH_HUBSPOT_REDIRECT_URL=
# Line
NUXT_OAUTH_LINE_CLIENT_ID=
NUXT_OAUTH_LINE_CLIENT_SECRET=
NUXT_OAUTH_LINE_REDIRECT_URL=
6 changes: 6 additions & 0 deletions playground/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const providers = computed(() =>
disabled: Boolean(user.value?.gitlab),
icon: 'i-simple-icons-gitlab',
},
{
label: user.value?.line || 'Line',
to: '/auth/line',
disabled: Boolean(user.value?.line),
icon: 'i-simple-icons-line',
},
{
label: user.value?.linear || 'Linear',
to: '/auth/linear',
Expand Down
1 change: 1 addition & 0 deletions playground/auth.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ declare module '#auth-utils' {
discord?: string
battledotnet?: string
keycloak?: string
line?: string
linear?: string
linkedin?: string
cognito?: string
Expand Down
12 changes: 12 additions & 0 deletions playground/server/routes/auth/line.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default defineOAuthLineEventHandler({
async onSuccess(event, { user }) {
await setUserSession(event, {
user: {
line: user.userId,
},
loggedInAt: Date.now(),
});

return sendRedirect(event, '/');
},
});
11 changes: 11 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,5 +354,16 @@ export default defineNuxtModule<ModuleOptions>({
clientSecret: '',
redirectURL: '',
})
// Line OAuth
runtimeConfig.oauth.line = defu(runtimeConfig.oauth.line, {
clientId: '',
clientSecret: '',
scope: [],
authorizationURL: '',
tokenURL: '',
userURL: '',
authorizationParams:{},
redirectURL: '',
})
},
})
2 changes: 1 addition & 1 deletion src/runtime/types/oauth-config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { H3Event, H3Error } from 'h3'

export type OAuthProvider = 'auth0' | 'authentik' | 'battledotnet' | 'cognito' | 'discord' | 'dropbox' | 'facebook' | 'github' | 'gitlab' | 'google' | 'hubspot' | 'instagram' | 'keycloak' | 'linear' | 'linkedin' | 'microsoft' | 'paypal' | 'polar' | 'spotify' | 'seznam' | 'steam' | 'strava' | 'tiktok' | 'twitch' | 'vk' | 'workos' | 'x' | 'xsuaa' | 'yandex' | 'zitadel' | (string & {})
export type OAuthProvider = 'auth0' | 'authentik' | 'battledotnet' | 'cognito' | 'discord' | 'dropbox' | 'facebook' | 'github' | 'gitlab' | 'google' | 'hubspot' | 'instagram' | 'keycloak' | 'line' | 'linear' | 'linkedin' | 'microsoft' | 'paypal' | 'polar' | 'spotify' | 'seznam' | 'steam' | 'strava' | 'tiktok' | 'twitch' | 'vk' | 'workos' | 'x' | 'xsuaa' | 'yandex' | 'zitadel' | (string & {})

export type OnError = (event: H3Event, error: H3Error) => Promise<void> | void

Expand Down

0 comments on commit 0f5e240

Please sign in to comment.