Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checks for auth token on app refresh #2793

Merged
merged 9 commits into from
Jan 10, 2023
4 changes: 3 additions & 1 deletion src/dispatch/static/dispatch/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const router = new Router({
routes: routes,
})

const authProviderSlug =
import.meta.env.VITE_DISPATCH_AUTHENTICATION_PROVIDER_SLUG || "dispatch-auth-provider-basic"

const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
Expand All @@ -36,7 +39,6 @@ router.beforeEach((to, from, next) => {
store.dispatch("app/setLoading", true)
if (to.matched.some((record) => record.meta.requiresAuth)) {
if (!store.state.auth.currentUser.loggedIn) {
let authProviderSlug = import.meta.env.VITE_DISPATCH_AUTHENTICATION_PROVIDER_SLUG
if (authProviderSlug === "dispatch-auth-provider-basic") {
basicAuthProvider.login(to, from, next)
} else if (authProviderSlug === "dispatch-auth-provider-pkce") {
Expand Down