mirror of
https://github.com/bitinflow/nuxt-oauth.git
synced 2026-03-13 13:45:59 +00:00
Make options optional
Revert default routes Update documentation
This commit is contained in:
@@ -50,8 +50,8 @@ export default defineNuxtConfig({
|
|||||||
ssr: false,
|
ssr: false,
|
||||||
// or
|
// or
|
||||||
routeRules: {
|
routeRules: {
|
||||||
'/account/**': {ssr: false},
|
'/dashboard/**': {ssr: false},
|
||||||
'/auth/**': {ssr: false}
|
'/whatever/**': {ssr: false}
|
||||||
},
|
},
|
||||||
|
|
||||||
// using code response type (default)
|
// using code response type (default)
|
||||||
|
|||||||
13
UPGRADE.md
13
UPGRADE.md
@@ -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
|
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.
|
`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',
|
|
||||||
},
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ export default defineNuxtConfig({
|
|||||||
ssr: false,
|
ssr: false,
|
||||||
|
|
||||||
oauth: {
|
oauth: {
|
||||||
|
redirect: {
|
||||||
|
home: '/home'
|
||||||
|
},
|
||||||
clientId: '98e1cb74-125a-4d60-b686-02c2f0c87521',
|
clientId: '98e1cb74-125a-4d60-b686-02c2f0c87521',
|
||||||
scope: ['user:read']
|
scope: ['user:read']
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ definePageMeta({
|
|||||||
|
|
||||||
const { $api } = useNuxtApp()
|
const { $api } = useNuxtApp()
|
||||||
|
|
||||||
$api.get('users/@me')
|
$api.get('user')
|
||||||
.then((response: any) => {
|
.then((response: any) => {
|
||||||
console.log(response.data)
|
console.log(response.data)
|
||||||
})
|
})
|
||||||
@@ -20,7 +20,7 @@ $api.get('users/@me')
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="user">
|
<div v-if="user">
|
||||||
Hello {{ user.name }}
|
Hello {{ user.data.first_name }}
|
||||||
|
|
||||||
<button @click="signOut">
|
<button @click="signOut">
|
||||||
Sign Out
|
Sign Out
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export default defineNuxtPlugin(async () => {
|
|||||||
const {bearerToken, accessToken} = await useAuth();
|
const {bearerToken, accessToken} = await useAuth();
|
||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: 'https://id.stream.tv/api/',
|
baseURL: 'https://accounts.bitinflow.com/api/v3/',
|
||||||
headers: {
|
headers: {
|
||||||
common: {
|
common: {
|
||||||
'Authorization': bearerToken(),
|
'Authorization': bearerToken(),
|
||||||
|
|||||||
@@ -3,32 +3,32 @@ import defu from "defu";
|
|||||||
|
|
||||||
// Module options TypeScript interface definition
|
// Module options TypeScript interface definition
|
||||||
export interface ModuleOptions {
|
export interface ModuleOptions {
|
||||||
redirect: {
|
redirect?: {
|
||||||
login: string,
|
login?: string,
|
||||||
logout: string,
|
logout?: string,
|
||||||
callback: string,
|
callback?: string,
|
||||||
home: string
|
home?: string
|
||||||
},
|
},
|
||||||
endpoints: {
|
endpoints?: {
|
||||||
authorization: string,
|
authorization?: string,
|
||||||
token: string,
|
token?: string,
|
||||||
userInfo: string,
|
userInfo?: string,
|
||||||
logout: string | null
|
logout?: string | null
|
||||||
},
|
},
|
||||||
refreshToken: {
|
refreshToken?: {
|
||||||
maxAge: number,
|
maxAge: number,
|
||||||
}
|
}
|
||||||
clientId: string,
|
clientId?: string,
|
||||||
responseType: 'token' | 'code',
|
responseType?: 'token' | 'code',
|
||||||
prompt: '' | 'none' | 'login' | 'consent',
|
prompt?: '' | 'none' | 'login' | 'consent',
|
||||||
scope: string[]
|
scope?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaults: ModuleOptions = {
|
const defaults: ModuleOptions = {
|
||||||
redirect: {
|
redirect: {
|
||||||
login: '/auth/login',
|
login: '/login',
|
||||||
logout: '/',
|
logout: '/',
|
||||||
callback: '/auth/login',
|
callback: '/login',
|
||||||
home: '/'
|
home: '/'
|
||||||
},
|
},
|
||||||
endpoints: {
|
endpoints: {
|
||||||
|
|||||||
Reference in New Issue
Block a user