Skip to content

Instantly share code, notes, and snippets.

@InfoSec812
Created April 17, 2019 16:28
Show Gist options
  • Save InfoSec812/bb1ab079afece9df796a0ddbefb7bc79 to your computer and use it in GitHub Desktop.
Save InfoSec812/bb1ab079afece9df796a0ddbefb7bc79 to your computer and use it in GitHub Desktop.
How to add `vue-authenticate` to a Quasar v1 application
import VueAuthenticate from 'vue-authenticate'
import VueCookies from 'vue-cookies'
export default async ({ Vue }) => {
const authPromise = new Promise(function(resolve, reject) {
Vue.use(VueCookies)
Vue.use(VueAuthenticate, {
baseUrl: 'http://localhost:3000', // Your API domain
providers: {
github: {
clientId: '',
redirectUri: 'http://localhost:8080/auth/callback' // Your client app URL
}
}
})
})
const axiosPromise = new Promise(function(resolve, reject) {
let loopCount = 0;
setInterval(function (t) { // Wait up to 2500ms for axios to be available in the Vue instance
loopCount++
if (Vue.prototype.hasOwnProperty('$axios')) {
resolve()
}
if (loopCount > 5) reject('Axios is not loaded')
}, 500)
})
await axiosPromise.then(() => authPromise)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment