Make options optional

Revert default routes
Update documentation
This commit is contained in:
René Preuß
2023-04-08 18:26:18 +02:00
parent 1560ae2038
commit 734b495ec0
6 changed files with 25 additions and 35 deletions

View File

@@ -50,8 +50,8 @@ export default defineNuxtConfig({
ssr: false,
// or
routeRules: {
'/account/**': {ssr: false},
'/auth/**': {ssr: false}
'/dashboard/**': {ssr: false},
'/whatever/**': {ssr: false}
},
// using code response type (default)

View File

@@ -11,16 +11,3 @@ is [not recommended](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-secu
want to use the `token` response type, you need to set it explicitly with `responseType: 'token'` in the
`oauth` configuration. Otherwise, you will use Authorization Code Grant with PKCE by default.
### Refactor default `login` and `callback` routes to `/auth/login`
We nested all authentication related routes under `/auth` prefix, so it aligned with our documentation and
provided a better default configuration. If you want to use the old routes, you need to update your `oauth`
configuration:
```
endpoints: {
login: '/login',
callback: '/login',
},
```

View File

@@ -4,6 +4,9 @@ export default defineNuxtConfig({
ssr: false,
oauth: {
redirect: {
home: '/home'
},
clientId: '98e1cb74-125a-4d60-b686-02c2f0c87521',
scope: ['user:read']
},

View File

@@ -9,7 +9,7 @@ definePageMeta({
const { $api } = useNuxtApp()
$api.get('users/@me')
$api.get('user')
.then((response: any) => {
console.log(response.data)
})
@@ -20,7 +20,7 @@ $api.get('users/@me')
<template>
<div v-if="user">
Hello {{ user.name }}
Hello {{ user.data.first_name }}
<button @click="signOut">
Sign Out

View File

@@ -7,7 +7,7 @@ export default defineNuxtPlugin(async () => {
const {bearerToken, accessToken} = await useAuth();
const api = axios.create({
baseURL: 'https://id.stream.tv/api/',
baseURL: 'https://accounts.bitinflow.com/api/v3/',
headers: {
common: {
'Authorization': bearerToken(),

View File

@@ -3,32 +3,32 @@ import defu from "defu";
// Module options TypeScript interface definition
export interface ModuleOptions {
redirect: {
login: string,
logout: string,
callback: string,
home: string
redirect?: {
login?: string,
logout?: string,
callback?: string,
home?: string
},
endpoints: {
authorization: string,
token: string,
userInfo: string,
logout: string | null
endpoints?: {
authorization?: string,
token?: string,
userInfo?: string,
logout?: string | null
},
refreshToken: {
refreshToken?: {
maxAge: number,
}
clientId: string,
responseType: 'token' | 'code',
prompt: '' | 'none' | 'login' | 'consent',
scope: string[]
clientId?: string,
responseType?: 'token' | 'code',
prompt?: '' | 'none' | 'login' | 'consent',
scope?: string[]
}
const defaults: ModuleOptions = {
redirect: {
login: '/auth/login',
login: '/login',
logout: '/',
callback: '/auth/login',
callback: '/login',
home: '/'
},
endpoints: {