From 5abc489b9954111d66d1385aa62a3ea962fa0a55 Mon Sep 17 00:00:00 2001
From: vnugent <public@vaughnnugent.com>
Date: Tue, 30 Jan 2024 15:23:06 -0500
Subject: merge upstream. Add dynamic client-side support for optional oauth2
 and social login methods

---
 front-end/src/views/Login/index.vue | 75 ++++++++++++++++++-------------------
 1 file changed, 36 insertions(+), 39 deletions(-)

(limited to 'front-end/src/views/Login/index.vue')

diff --git a/front-end/src/views/Login/index.vue b/front-end/src/views/Login/index.vue
index 6a55aeb..476ebf4 100644
--- a/front-end/src/views/Login/index.vue
+++ b/front-end/src/views/Login/index.vue
@@ -1,3 +1,38 @@
+<script setup lang="ts">
+import { computed } from 'vue'
+import { apiCall, useWait } from '@vnuge/vnlib.browser'
+import { isNil } from 'lodash-es'
+import { useStore } from '../../store'
+import { storeToRefs } from 'pinia'
+import UserPass from './components/UserPass.vue'
+import Social from './components/Social.vue'
+
+const store = useStore();
+const { loggedIn } = storeToRefs(store)
+const pkiEnabled = computed(() => !isNil(store.pki?.pkiAuth))
+
+store.setPageTitle('Login')
+
+const { waiting } = useWait()
+
+const submitLogout = async () => {
+  //Submit logout request
+  await apiCall(async ({ toaster }) => {
+    const { logout } = await store.socialOauth()
+    // Attempt to logout
+    await logout()
+    // Push a new toast message
+    toaster.general.success({
+      id: 'logout-success',
+      title: 'Success',
+      text: 'You have been logged out',
+      duration: 5000
+    })
+  })
+}
+
+</script>
+
 <template>
   <div id="login-template" class="app-component-entry">
     <div class="login-container">
@@ -25,7 +60,7 @@
         <Social />
 
         <!-- pki button, forward to the pki route -->
-        <div v-if="pkiEnabled" class="mt-3">
+        <div v-if="pkiEnabled" class="mt-4">
           <router-link to="/login/pki">
             <button type="submit" class="btn red social-button" :disabled="waiting">
               <fa-icon :icon="['fa','certificate']" size="xl" />
@@ -39,44 +74,6 @@
   </div>
 </template>
 
-<script setup lang="ts">
-import {  } from 'vue'
-import { apiCall, useWait } from '@vnuge/vnlib.browser'
-import { isNil } from 'lodash-es'
-import { useStore } from '../../store'
-import { storeToRefs } from 'pinia'
-import UserPass from './components/UserPass.vue'
-import Social from './components/Social.vue'
-
-//pki enabled flag from env
-const pkiEnabled = !isNil(import.meta.env.VITE_PKI_ENABLED);
-
-const store = useStore();
-const { loggedIn } = storeToRefs(store)
-
-store.setPageTitle('Login')
-
-const { waiting } = useWait()
-
-const submitLogout = async () => {
-  //Submit logout request
-  await apiCall(async ({ toaster }) => {
-    // Attempt to logout
-    const { logout } = await store.socialOauth()
-    await logout()
-    
-    // Push a new toast message
-    toaster.general.success({
-      id: 'logout-success',
-      title: 'Success',
-      text: 'You have been logged out',
-      duration: 5000
-    })
-  })
-}
-
-</script>
-
 <style lang="scss">
 #login-template {
   .login-container{
-- 
cgit 

