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/views/Login/components/Social.vue | |
parent | b564708f29cf8a709c3e3d981477b2ec8440673e (diff) |
log time coming ui and lib updates
Diffstat (limited to 'front-end/src/views/Login/components/Social.vue')
-rw-r--r-- | front-end/src/views/Login/components/Social.vue | 55 |
1 files changed, 19 insertions, 36 deletions
diff --git a/front-end/src/views/Login/components/Social.vue b/front-end/src/views/Login/components/Social.vue index 5824226..2cea930 100644 --- a/front-end/src/views/Login/components/Social.vue +++ b/front-end/src/views/Login/components/Social.vue @@ -1,47 +1,30 @@ <template> - - <form class="w-full" @submit.prevent="SocalLogin('/login/social/github')"> - <button type="submit" class="btn social-button" :disabled="waiting"> - <fa-icon :icon="['fab','github']" size="xl" /> - Login with Github - </button> - </form> - <form class="mt-4" @submit.prevent="SocalLogin('/login/social/discord')"> - <button type="submit" class="btn social-button" :disabled="waiting"> - <fa-icon :icon="['fab','discord']" size="xl" /> - Login with Discord - </button> - </form> + <div class="flex flex-col gap-3"> + <div v-for="method in store.socialOauth.methods" :key="method.Id" class=""> + <button + type="submit" + class="btn social-button" + :disabled="waiting" + @click.prevent="submitLogin(method)" + > + <fa-icon :icon="['fab', method.Id]" size="xl" /> + Login with {{ capitalize(method.Id) }} + </button> + </div> + </div> </template> <script setup lang="ts"> -import { apiCall, useWait, useSessionUtils, WebMessage, useUser } from '@vnuge/vnlib.browser' +import { apiCall, useWait, type OAuthMethod } from '@vnuge/vnlib.browser' +import { capitalize } from 'lodash-es'; +import { useStore } from '../../../store'; const { waiting } = useWait() -const { KeyStore } = useSessionUtils() -const { prepareLogin } = useUser() +const store = useStore() -const SocalLogin = async (url:string) => { - await apiCall(async ({ axios }) => { - - //Prepare the login claim - const claim = await prepareLogin() - const { data } = await axios.put<WebMessage<string>>(url, claim) - - const encDat = data.getResultOrThrow() - // Decrypt the result which should be a redirect url - const result = await KeyStore.decryptDataAsync(encDat) - // get utf8 text - const text = new TextDecoder('utf-8').decode(result) - // Recover url - const redirect = new URL(text) - // Force https - redirect.protocol = 'https:' - // redirect to the url - window.location.href = redirect.href - }) -} +//Invoke login wrapped in api call +const submitLogin = (method: OAuthMethod) => apiCall(() => store.socialOauth.beginLoginFlow(method)) </script>
\ No newline at end of file |