fix: lint-error

This commit is contained in:
2020-06-21 19:06:41 +02:00
parent 84843cc3ed
commit 27ff91ed0b
6 changed files with 253 additions and 232 deletions
+7 -4
View File
@@ -1,13 +1,16 @@
import { ApolloClient } from 'apollo-client'
import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory'
import {
InMemoryCache,
IntrospectionFragmentMatcher
} from 'apollo-cache-inmemory'
import { createHttpLink } from 'apollo-link-http'
import { setContext } from 'apollo-link-context'
import { useAuth } from './auth'
import { provide } from '@vue/composition-api'
import introspectionQueryResultData from '../fragmentTypes.json'
import { onGlobalSetup } from 'nuxt-composition-api'
import { DefaultApolloClient } from '@vue/apollo-composable'
import Vue from 'vue'
import introspectionQueryResultData from '../fragmentTypes.json'
import { useAuth } from './auth'
const apiUrl = process.env.graphqlApi || '/query'
@@ -21,7 +24,7 @@ const httpLink = createHttpLink({
uri: apiUrl
})
const getToken = async (options) => {
const getToken = async options => {
const { getTokenSilently } = useAuth()
return getTokenSilently.value(options)
}
+2 -2
View File
@@ -10,6 +10,7 @@ let instance
const params = new URL(window.location).searchParams
const domain = params.get('domain') || 'unbound.eu.auth0.com'
// eslint-disable-next-line import/prefer-default-export
export const useAuth = (onRedirectCallback = DEFAULT_REDIRECT_CALLBACK) => {
if (instance) {
return toRefs(instance)
@@ -105,14 +106,12 @@ export const useAuth = (onRedirectCallback = DEFAULT_REDIRECT_CALLBACK) => {
instance.auth0Client = createAuth0Client(options)
instance.auth0Client.then(client => {
instance.loading = true
// instance.auth0Client = client
try {
// If the user is returning to the app after authentication..
if (
window.location.search.includes('code=') &&
window.location.search.includes('state=')
) {
console.log('location search', window.location.search)
// handle the redirect and retrieve tokens
client
.handleRedirectCallback()
@@ -123,6 +122,7 @@ export const useAuth = (onRedirectCallback = DEFAULT_REDIRECT_CALLBACK) => {
// Initialize our internal authentication state
fetchUser()
})
// eslint-disable-next-line no-console
.catch(e => console.error('error handling redirect callback', e))
} else {
fetchUser()