diff options
author | vnugent <public@vaughnnugent.com> | 2023-12-13 17:58:51 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-12-13 17:58:51 -0500 |
commit | 4b8ae76132d2342f40cec703b3d5145ea075c451 (patch) | |
tree | 62b942b6181261566cd3245ee35cd15a138aabf2 /front-end/src/store/socialMfaPlugin.ts | |
parent | b564708f29cf8a709c3e3d981477b2ec8440673e (diff) |
log time coming ui and lib updates
Diffstat (limited to 'front-end/src/store/socialMfaPlugin.ts')
-rw-r--r-- | front-end/src/store/socialMfaPlugin.ts | 42 |
1 files changed, 42 insertions, 0 deletions
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<typeof useSocialOauthLogin> + } +} + +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 |