Skip to content

Commit 5c79590

Browse files
authored
feat: add authorizationParams in oauth config (#56)
* feat: add authorizationParams in oauth config * fix: improve GH error handling
1 parent 6a6043a commit 5c79590

25 files changed

+164
-62
lines changed

playground/app.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,67 +3,67 @@ const { loggedIn, user, session, clear } = useUserSession()
33
44
const providers = computed(() => [
55
{
6-
label: session.value.user?.github?.login || 'GitHub',
6+
label: session.value.user?.github || 'GitHub',
77
to: '/auth/github',
88
disabled: Boolean(user.value?.github),
99
icon: 'i-simple-icons-github',
1010
},
1111
{
12-
label: session.value.user?.spotify?.display_name || 'Spotify',
12+
label: session.value.user?.spotify || 'Spotify',
1313
to: '/auth/spotify',
1414
disabled: Boolean(user.value?.spotify),
1515
icon: 'i-simple-icons-spotify',
1616
},
1717
{
18-
label: session.value.user?.google?.email || 'Google',
18+
label: session.value.user?.google || 'Google',
1919
to: '/auth/google',
2020
disabled: Boolean(user.value?.google),
2121
icon: 'i-simple-icons-google',
2222
},
2323
{
24-
label: session.value.user?.twitch?.login || 'Twitch',
24+
label: session.value.user?.twitch || 'Twitch',
2525
to: '/auth/twitch',
2626
disabled: Boolean(user.value?.twitch),
2727
icon: 'i-simple-icons-twitch',
2828
},
2929
{
30-
label: user.value?.auth0?.email || 'Auth0',
30+
label: user.value?.auth0 || 'Auth0',
3131
to: '/auth/auth0',
3232
disabled: Boolean(user.value?.auth0),
3333
icon: 'i-simple-icons-auth0',
3434
},
3535
{
36-
label: user.value?.discord?.username || 'Discord',
36+
label: user.value?.discord || 'Discord',
3737
to: '/auth/discord',
3838
disabled: Boolean(user.value?.discord),
3939
icon: 'i-simple-icons-discord',
4040
},
4141
{
42-
label: user.value?.battledotnet?.battletag || 'Battle.net',
42+
label: user.value?.battledotnet || 'Battle.net',
4343
to: '/auth/battledotnet',
4444
disabled: Boolean(user.value?.battledotnet),
4545
icon: 'i-simple-icons-battledotnet',
4646
},
4747
{
48-
label: user.value?.microsoft?.displayName || 'Microsoft',
48+
label: user.value?.microsoft || 'Microsoft',
4949
to: '/auth/microsoft',
5050
disabled: Boolean(user.value?.microsoft),
5151
icon: 'i-simple-icons-microsoft',
5252
},
5353
{
54-
label: user.value?.keycloak?.preferred_username || 'Keycloak',
54+
label: user.value?.keycloak || 'Keycloak',
5555
to: '/auth/keycloak',
5656
disabled: Boolean(user.value?.keycloak),
5757
icon: 'i-simple-icons-redhat'
5858
},
5959
{
60-
label: user.value?.linkedin?.email || 'LinkedIn',
60+
label: user.value?.linkedin || 'LinkedIn',
6161
to: '/auth/linkedin',
6262
disabled: Boolean(user.value?.linkedin),
6363
icon: 'i-simple-icons-linkedin',
6464
},
6565
{
66-
label: user.value?.cognito?.email || 'Cognito',
66+
label: user.value?.cognito || 'Cognito',
6767
to: '/auth/cognito',
6868
disabled: Boolean(user.value?.cognito),
6969
icon: 'i-simple-icons-amazonaws',

playground/auth.d.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
declare module '#auth-utils' {
22
interface User {
3-
spotify?: any
4-
github?: any
5-
google?: any
6-
twitch?: any
7-
auth0?: any
8-
microsoft?: any;
9-
discord?: any
10-
battledotnet?: any
11-
keycloak?: any
12-
linkedin?: any
3+
spotify?: string
4+
github?: string
5+
google?: string
6+
twitch?: string
7+
auth0?: string
8+
microsoft?: string
9+
discord?: string
10+
battledotnet?: string
11+
keycloak?: string
12+
linkedin?: string
13+
cognito?: string
1314
}
1415

1516
interface UserSession {

playground/server/routes/auth/auth0.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default oauth.auth0EventHandler({
55
async onSuccess(event, { user }) {
66
await setUserSession(event, {
77
user: {
8-
auth0: user,
8+
auth0: user.email
99
},
1010
loggedInAt: Date.now()
1111
})

playground/server/routes/auth/battledotnet.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default oauth.battledotnetEventHandler({
22
async onSuccess(event, { user }) {
33
await setUserSession(event, {
44
user: {
5-
battledotnet: user,
5+
battledotnet: user.battletag
66
},
77
loggedInAt: Date.now()
88
})

playground/server/routes/auth/cognito.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default oauth.cognitoEventHandler({
22
async onSuccess(event, { user }) {
33
await setUserSession(event, {
44
user: {
5-
cognito: user,
5+
cognito: user.email
66
},
77
loggedInAt: Date.now()
88
})

playground/server/routes/auth/discord.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default oauth.discordEventHandler({
22
async onSuccess(event, { user }) {
33
await setUserSession(event, {
44
user: {
5-
discord: user,
5+
discord: user.username
66
},
77
loggedInAt: Date.now()
88
})

playground/server/routes/auth/github.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default oauth.githubEventHandler({
22
async onSuccess(event, { user }) {
33
await setUserSession(event, {
44
user: {
5-
github: user,
5+
github: user.login
66
},
77
loggedInAt: Date.now()
88
})

playground/server/routes/auth/google.get.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
export default oauth.googleEventHandler({
2+
config: {
3+
authorizationParams: {
4+
access_type: 'offline'
5+
}
6+
},
27
async onSuccess(event, { user }) {
38
await setUserSession(event, {
49
user: {
5-
google: user,
10+
google: user.email
611
},
712
loggedInAt: Date.now()
813
})

playground/server/routes/auth/keycloak.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default oauth.keycloakEventHandler({
22
async onSuccess(event, { user }) {
33
await setUserSession(event, {
44
user: {
5-
keycloak: user,
5+
keycloak: user.preferred_username
66
},
77
loggedInAt: Date.now(),
88
})

playground/server/routes/auth/linkedin.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default oauth.linkedinEventHandler({
55
async onSuccess(event, { user }) {
66
await setUserSession(event, {
77
user: {
8-
linkedin: user,
8+
linkedin: user.email
99
},
1010
loggedInAt: Date.now()
1111
})

0 commit comments

Comments
 (0)