From 4b8ae76132d2342f40cec703b3d5145ea075c451 Mon Sep 17 00:00:00 2001 From: vnugent Date: Wed, 13 Dec 2023 17:58:51 -0500 Subject: log time coming ui and lib updates --- front-end/src/store/socialMfaPlugin.ts | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 front-end/src/store/socialMfaPlugin.ts (limited to 'front-end/src/store/socialMfaPlugin.ts') diff --git a/front-end/src/store/socialMfaPlugin.ts b/front-end/src/store/socialMfaPlugin.ts new file mode 100644 index 0000000..d328399 --- /dev/null +++ b/front-end/src/store/socialMfaPlugin.ts @@ -0,0 +1,42 @@ + +import 'pinia' +import { } from 'vue'; +import { useSocialOauthLogin, createSocialMethod, useUser } from '@vnuge/vnlib.browser' +import { } from '@vueuse/core'; +import { PiniaPluginContext, PiniaPlugin, storeToRefs } from 'pinia' +import { } from 'lodash-es'; + +declare module 'pinia' { + export interface PiniaCustomProperties { + socialOauth: ReturnType + } +} + +export const socialMfaPlugin: PiniaPlugin = ({ store }: PiniaPluginContext) => { + + const { } = storeToRefs(store) + const { logout } = useUser() + + //Setup social providers + const socialOauth = useSocialOauthLogin([ + //createSocialMethod('github', '/login/social/github'), + //createSocialMethod('discord', '/login/social/discord'), + ]) + + /** + * Override the logout function to default to a social logout, + * if the social logout fails, then we will logout the user + */ + + const logoutFunc = socialOauth.logout; + + (socialOauth as any).logout = async () => { + if (await logoutFunc() === false) { + await logout() + } + } + + return { + socialOauth + } +} \ No newline at end of file -- cgit