AuthProvider.vue 1.06 KB
<script setup lang="ts">
import { useTheme } from 'vuetify'
import keycloakInstance from '@/keycloak'

function login() {
  keycloakInstance.login({
    redirectUri: `${window.location.origin}/naputpro/beranda/profile`,
  })
}

onMounted(() => {
  if (keycloakInstance.authenticated)
    router.push('/naputpro/beranda/profile')
})

const { global } = useTheme()

const authProviders = [
  {
    icon: 'bxl-facebook',
    color: '#4267b2',
    colorInDark: '#4267b2',
  },
  {
    icon: 'bxl-twitter',
    color: '#1da1f2',
    colorInDark: '#1da1f2',
  },
  {
    icon: 'bxl-github',
    color: '#272727',
    colorInDark: '#fff',
  },
  {
    icon: 'bxl-google',
    color: '#db4437',
    colorInDark: '#db4437',
  },
]
</script>

<template>
  <VBtn
    v-for="link in authProviders"
    :key="link.icon"
    :icon="link.icon"
    variant="text"
    size="small"
    :color="global.name.value === 'dark' ? link.colorInDark : link.color"
  />
  <VBtn
    color="warning"
    @click="login"
  >
    <VIcon
      start
      icon="ri-login-box-line"
    /> Login SSO
  </VBtn>
</template>