fix: commit vendored @kuns/zitadel-auth dist (was excluded by dist/ gitignore)
This commit is contained in:
38
vendor/zitadel-auth/dist/vue.js
vendored
Normal file
38
vendor/zitadel-auth/dist/vue.js
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import {
|
||||
ZitadelAuth
|
||||
} from "./chunk-NFH7JLJM.js";
|
||||
|
||||
// src/adapters/vue.ts
|
||||
import { reactive, toRefs } from "vue";
|
||||
function useZitadelAuth(router, config) {
|
||||
const auth = new ZitadelAuth(config);
|
||||
const state = reactive({
|
||||
isAuthenticated: false,
|
||||
isLoading: true,
|
||||
user: null,
|
||||
error: null
|
||||
});
|
||||
auth.onAuthChange((s) => {
|
||||
state.isAuthenticated = s.isAuthenticated;
|
||||
state.isLoading = s.isLoading;
|
||||
state.user = s.user;
|
||||
state.error = s.error;
|
||||
});
|
||||
const initPromise = auth.init();
|
||||
router.beforeEach(async (to) => {
|
||||
if (to.path.includes("/auth/callback")) return true;
|
||||
await initPromise;
|
||||
if (auth.isAuthenticated) return true;
|
||||
auth.login();
|
||||
return false;
|
||||
});
|
||||
return {
|
||||
...toRefs(state),
|
||||
login: () => auth.login(),
|
||||
logout: () => auth.logout(),
|
||||
fetch: (url, init) => auth.fetch(url, init)
|
||||
};
|
||||
}
|
||||
export {
|
||||
useZitadelAuth
|
||||
};
|
||||
Reference in New Issue
Block a user