-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCAHFSAuth.vue
More file actions
71 lines (63 loc) · 2.02 KB
/
Copy pathCAHFSAuth.vue
File metadata and controls
71 lines (63 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<template>
<div>
<ContentBlock content-block-name="cahfs-login"></ContentBlock>
<q-card
flat
bordered
class="bg-ucdavis-blue-10 q-mt-md"
>
<q-card-section class="row items-start no-wrap">
<q-icon
name="login"
color="primary"
size="sm"
class="q-mr-md"
/>
<div>
<h2 class="text-subtitle1 text-weight-bold text-primary q-mt-none q-mb-xs">Members sign-in</h2>
<div class="text-body2">
Sign in with your UC Davis account to open web reports and section pages.
</div>
<q-btn
:href="loginHref"
type="a"
color="primary"
no-caps
label="Sign in"
class="q-mt-md"
/>
</div>
</q-card-section>
</q-card>
</div>
</template>
<script setup lang="ts">
import { useQuasar } from "quasar"
import { inject, onMounted } from "vue"
import { useRouter } from "vue-router"
import { useFetch } from "@/composables/ViperFetch"
import { useUserStore } from "@/store/UserStore"
import { getLoginUrl } from "@/composables/RequireLogin"
import ContentBlock from "@/CMS/components/ContentBlock.vue"
const router = useRouter()
const baseUrl = inject<string>("apiURL")
const userStore = useUserStore()
const $q = useQuasar()
const loginHref = getLoginUrl()
async function checkAuth() {
$q.loading.show({
message: "Checking for log in",
delay: 250,
})
const { get } = useFetch()
const r = await get(baseUrl + "loggedInUser")
if (r.success && r.result.userId) {
userStore.loadUser(r.result)
}
$q.loading.hide()
if (userStore.isLoggedIn) {
router.push({ name: "CAHFSHome" })
}
}
onMounted(() => checkAuth())
</script>