Skip to content

Commit

Permalink
fix gh login UI (#48)
Browse files Browse the repository at this point in the history
fix: gh login UI

Co-authored-by: Christopher Langton <chris@langton.cloud>
  • Loading branch information
0x73746F66 and chrisdlangton authored Sep 26, 2024
1 parent 663e5d7 commit ccb98fd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ run: ## FOR DOCO ONLY - Run these one at a time, do not call this target directl
npm run preview

git-demo:
git stash save "changes for demo"
[[ -z "$(shell git status -s)" ]] || git stash save "changes for demo"
git checkout main
git branch -D demo
git fetch -a
git pull
git checkout -b demo main
git push --set-upstream origin demo
git stash pop
git stash pop || true

_helpers: ## FOR DOCO ONLY
npx wrangler d1 execute vulnetix --local --file ./migrations/0001_init.sql
Expand Down
13 changes: 11 additions & 2 deletions src/layouts/components/DefaultLayoutWithVerticalNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Footer from '@/layouts/components/Footer.vue'
import NavbarThemeSwitcher from '@/layouts/components/NavbarThemeSwitcher.vue'
import NavSearchBar from '@/layouts/components/NavSearchBar.vue'
import UserProfile from '@/layouts/components/UserProfile.vue'
import { useMemberStore } from '@/stores/member'
import { useNotificationsStore } from '@/stores/notifications'
import { timeAgo } from '@/utils'
import Notifications from '@core/components/Notifications.vue'
Expand All @@ -19,6 +20,8 @@ const icons = {
'mend': mendIcon,
}
const Member = useMemberStore()
const { isLoggedIn } = storeToRefs(Member)
const NotificationsStore = useNotificationsStore()
const notifications = ref(NotificationsStore.state)
NotificationsStore.state.map(notification => {
Expand All @@ -37,7 +40,10 @@ watch(NotificationsStore, () => {

<template>
<VerticalNavLayout>
<template #navbar="{ toggleVerticalOverlayNavActive }">
<template
v-if="isLoggedIn"
#navbar="{ toggleVerticalOverlayNavActive }"
>
<div class="d-flex h-100 align-center">
<IconBtn
class="ms-n3 d-lg-none"
Expand Down Expand Up @@ -69,7 +75,10 @@ watch(NotificationsStore, () => {
</div>
</template>

<template #vertical-nav-content>
<template
v-if="isLoggedIn"
#vertical-nav-content
>
<VerticalNavLink :item="{
title: 'Dashboard',
icon: 'bx-home',
Expand Down
2 changes: 2 additions & 0 deletions src/pages/GitHub.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Controller {
if (this.urlQuery?.setup_action === 'install' && this.urlQuery?.installation_id) {
this.install(this.urlQuery.code, this.urlQuery.installation_id)
} else {
Member.logout()
this.login(this.urlQuery.code)
}
} else {
Expand Down Expand Up @@ -593,6 +594,7 @@ const controller = reactive(new Controller())
</template>
</VEmptyState>
<VTabs
v-if="!state.showEmptyState"
v-model="tabs"
:bgColor="global.name.value === 'dark' ? 'rgb(var(--v-theme-primary))' : 'rgba(var(--v-theme-primary),var(--v-activated-opacity))'"
:color="global.name.value === 'dark' ? '#272727' : 'rgba(var(--v-theme-on-surface),var(--v-medium-emphasis-opacity))'"
Expand Down
7 changes: 3 additions & 4 deletions src/stores/member.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const useMemberStore = defineStore('member', {
alertFindings: 0,
alertType: 0,
theme,
isLoggedIn: client.isLoggedIn(),
}),
actions: {
async ensureSession() {
Expand All @@ -29,18 +30,16 @@ export const useMemberStore = defineStore('member', {
secret: '',
expiry: '',
}
this.isLoggedIn = client.isLoggedIn()
},
async logout() {
this.isLoggedIn = false
this.session = {
kid: '',
secret: '',
expiry: '',
}
await client.deleteKey(`session`)
},
isLoggedIn() {
//TODO: check this.session.expiry
return !!this.session.secret
},
},
})

0 comments on commit ccb98fd

Please sign in to comment.