Skip to content

Commit 29f3106

Browse files
committed
2 parents bc64538 + 1b296e2 commit 29f3106

File tree

11 files changed

+416
-180
lines changed

11 files changed

+416
-180
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
# Changelog
22

33

4+
## v0.0.6
5+
6+
[compare changes](https://github.com/Atinux/nuxt-auth-utils/compare/v0.0.5...v0.0.6)
7+
8+
### 🚀 Enhancements
9+
10+
- Added discord auth provider ([#7](https://github.com/Atinux/nuxt-auth-utils/pull/7))
11+
- Added oauth battle.net ([#11](https://github.com/Atinux/nuxt-auth-utils/pull/11))
12+
- Refactor login buttons to use dropdown ([#14](https://github.com/Atinux/nuxt-auth-utils/pull/14))
13+
14+
### 🏡 Chore
15+
16+
- Update deps ([05f4a9c](https://github.com/Atinux/nuxt-auth-utils/commit/05f4a9c))
17+
18+
### ❤️ Contributors
19+
20+
- Sébastien Chopin ([@Atinux](http://github.com/Atinux))
21+
- Arash
22+
- Samuel LEFEVRE
23+
24+
425
## v0.0.5
526

627
[compare changes](https://github.com/Atinux/nuxt-auth-utils/compare/v0.0.4...v0.0.5)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export default defineNuxtConfig({
142142
```
143143

144144
It can also be set using environment variables:
145+
145146
- `NUXT_OAUTH_<PROVIDER>_CLIENT_ID`
146147
- `NUXT_OAUTH_<PROVIDER>_CLIENT_SECRET`
147148

@@ -153,6 +154,7 @@ It can also be set using environment variables:
153154
- Google
154155
- Spotify
155156
- Twitch
157+
- Battle.net
156158

157159
You can add your favorite provider by creating a new file in [src/runtime/server/lib/oauth/](./src/runtime/server/lib/oauth/).
158160

@@ -183,7 +185,6 @@ export default oauth.githubEventHandler({
183185

184186
Make sure to set the callback URL in your OAuth app settings as `<your-domain>/auth/github`.
185187

186-
187188
## Development
188189

189190
```bash

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuxt-auth-utils",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "Minimalist Auth module for Nuxt with SSR",
55
"repository": "Atinux/nuxt-auth-utils",
66
"license": "MIT",
@@ -36,20 +36,20 @@
3636
"ohash": "^1.1.3"
3737
},
3838
"devDependencies": {
39-
"@iconify-json/simple-icons": "^1.1.76",
39+
"@iconify-json/simple-icons": "^1.1.78",
4040
"@nuxt/devtools": "latest",
4141
"@nuxt/eslint-config": "^0.2.0",
42-
"@nuxt/module-builder": "^0.5.2",
42+
"@nuxt/module-builder": "^0.5.4",
4343
"@nuxt/schema": "^3.8.1",
4444
"@nuxt/test-utils": "^3.8.1",
4545
"@nuxt/ui": "^2.10.0",
4646
"@nuxt/ui-pro": "^0.4.2",
47-
"@types/node": "^20.8.9",
47+
"@types/node": "^20.9.0",
4848
"changelogen": "^0.5.5",
49-
"eslint": "^8.52.0",
49+
"eslint": "^8.53.0",
5050
"nuxt": "^3.8.1",
5151
"typescript": "^5.2.2",
52-
"vitest": "^0.33.0",
52+
"vitest": "^0.34.6",
5353
"vue-tsc": "^1.8.22"
5454
}
5555
}

playground/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ NUXT_OAUTH_AUTH0_DOMAIN=
1818
# Discord
1919
NUXT_OAUTH_DISCORD_CLIENT_ID=
2020
NUXT_OAUTH_DISCORD_CLIENT_SECRET=
21+
# Battle.net OAuth
22+
NUXT_OAUTH_BATTLEDOTNET_CLIENT_ID=
23+
NUXT_OAUTH_BATTLEDOTNET_CLIENT_SECRET=

playground/app.vue

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,69 @@
1-
<script setup>
2-
const { loggedIn, session, clear } = useUserSession()
1+
<script setup lang="ts">
2+
const { loggedIn, user, session, clear } = useUserSession()
3+
4+
const providers = computed(() => [
5+
{
6+
label: session.value.user?.github?.login || 'GitHub',
7+
to: '/auth/github',
8+
disabled: Boolean(user.value?.github),
9+
icon: 'i-simple-icons-github',
10+
},
11+
{
12+
label: session.value.user?.spotify?.display_name || 'Spotify',
13+
to: '/auth/spotify',
14+
disabled: Boolean(user.value?.spotify),
15+
icon: 'i-simple-icons-spotify',
16+
},
17+
{
18+
label: session.value.user?.google?.email || 'Google',
19+
to: '/auth/google',
20+
disabled: Boolean(user.value?.google),
21+
icon: 'i-simple-icons-google',
22+
},
23+
{
24+
label: session.value.user?.twitch?.login || 'Twitch',
25+
to: '/auth/twitch',
26+
disabled: Boolean(user.value?.twitch),
27+
icon: 'i-simple-icons-twitch',
28+
},
29+
{
30+
label: user.value?.auth0?.email || 'Auth0',
31+
to: '/auth/auth0',
32+
disabled: Boolean(user.value?.auth0),
33+
icon: 'i-simple-icons-auth0',
34+
},
35+
{
36+
label: user.value?.discord?.username || 'Discord',
37+
to: '/auth/discord',
38+
disabled: Boolean(user.value?.discord),
39+
icon: 'i-simple-icons-discord',
40+
},
41+
{
42+
label: user.value?.battledotnet?.battletag || 'Battle.net',
43+
to: '/auth/battledotnet',
44+
disabled: Boolean(user.value?.battledotnet),
45+
icon: 'i-simple-icons-battledotnet',
46+
},
47+
].map(p => ({
48+
...p,
49+
prefetch: false,
50+
external: true,
51+
})))
352
</script>
453

554
<template>
655
<UHeader>
756
<template #right>
8-
<UButton
9-
v-if="!loggedIn || !session.user.github"
10-
to="/auth/github"
11-
icon="i-simple-icons-github"
12-
external
13-
color="gray"
14-
size="xs"
15-
>
16-
Login with GitHub
17-
</UButton>
18-
<UButton
19-
v-if="!loggedIn || !session.user.spotify"
20-
to="/auth/spotify"
21-
icon="i-simple-icons-spotify"
22-
external
23-
color="gray"
24-
size="xs"
25-
>
26-
Login with Spotify
27-
</UButton>
28-
<UButton
29-
v-if="!loggedIn || !session.user.google"
30-
to="/auth/google"
31-
icon="i-simple-icons-google"
32-
external
33-
color="gray"
34-
size="xs"
35-
>
36-
Login with Google
37-
</UButton>
38-
<UButton
39-
v-if="!loggedIn || !session.user.twitch"
40-
to="/auth/twitch"
41-
icon="i-simple-icons-twitch"
42-
external
43-
color="gray"
44-
size="xs"
45-
>
46-
Login with Twitch
47-
</UButton>
48-
<UButton
49-
v-if="!loggedIn || !session.user.auth0"
50-
to="/auth/auth0"
51-
icon="i-simple-icons-auth0"
52-
external
53-
color="gray"
54-
size="xs"
55-
>
56-
Login with Auth0
57-
</UButton>
58-
<UButton
59-
v-if="!loggedIn || !session.user.discord"
60-
to="/auth/discord"
61-
icon="i-simple-icons-discord"
62-
external
63-
color="gray"
64-
size="xs"
65-
>
66-
Login with Discord
67-
</UButton>
57+
<UDropdown :items="[providers]">
58+
<UButton
59+
icon="i-heroicons-chevron-down"
60+
trailing
61+
color="gray"
62+
size="xs"
63+
>
64+
Login with
65+
</UButton>
66+
</UDropdown>
6867
<UButton
6968
v-if="loggedIn"
7069
color="gray"

playground/auth.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ declare module '#auth-utils' {
77
twitch?: any
88
auth0?: any
99
discord?: any
10+
battledotnet?: any
1011
}
1112
loggedInAt: number
1213
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default oauth.battledotnetEventHandler({
2+
async onSuccess(event, { user }) {
3+
await setUserSession(event, {
4+
user: {
5+
battledotnet: user,
6+
},
7+
loggedInAt: Date.now()
8+
})
9+
10+
return sendRedirect(event, '/')
11+
}
12+
})

0 commit comments

Comments
 (0)