diff --git a/src/components/ChatWidget.vue b/src/components/ChatWidget.vue index eca32ed..853abbc 100644 --- a/src/components/ChatWidget.vue +++ b/src/components/ChatWidget.vue @@ -31,8 +31,9 @@ import 'prismjs/themes/prism.css'; // Choose a theme you like import { v4 as uuidv4 } from 'uuid'; import axios from 'axios'; - import { inject } from 'vue'; + import { inject, onMounted, ref } from 'vue'; import { obpApiHostKey } from '@/obp/keys'; + import { getCurrentUser } from '../obp'; import { Check, Close } from '@element-plus/icons-vue' import 'prismjs/components/prism-markup'; @@ -43,7 +44,6 @@ import 'prismjs/components/prism-python'; import 'prismjs/components/prism-go'; import 'prismjs/themes/prism-okaidia.css'; - export default { data() { @@ -53,11 +53,13 @@ messages: [], sessionId: uuidv4(), isLoading: false, - obpApiHost: null + obpApiHost: null, + isLoggedIn: null, }; }, created() { this.obpApiHost = inject(obpApiHostKey); + this.checkLoginStatus(); }, methods: { toggleChat() { @@ -68,6 +70,16 @@ } }); }, + async checkLoginStatus() { + const currentUser = await getCurrentUser() + const currentResponseKeys = Object.keys(currentUser) + if (currentResponseKeys.includes('username')) { + this.isLoggedIn = true + } else { + this.isLoggedIn = null + } + console.log(`Logged In:${this.isLoggedIn}`) + }, async sendMessage() { if (this.userInput.trim()) { const newMessage = { role: 'user', content: this.userInput }; @@ -196,7 +208,7 @@ Chat with Opey Powered by OpenAI -
+
@@ -240,9 +252,26 @@
+
+

Opey is only availabled when logged in. Log In

+
- - + + + +