Created
April 17, 2019 16:28
-
-
Save InfoSec812/bb1ab079afece9df796a0ddbefb7bc79 to your computer and use it in GitHub Desktop.
How to add `vue-authenticate` to a Quasar v1 application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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