remove keycloak change use cookie only

This commit is contained in:
Warunee Tamkoo 2024-08-28 11:14:21 +07:00
parent 24374ab8f2
commit 92b85ce4ef
23 changed files with 236 additions and 189 deletions

View file

@ -12,15 +12,16 @@ import type {
SupportUserStatus,
SupportMessageStatus,
} from "@/modules/00_support/interface/index/Main";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { getToken, tokenParsed } from "@/plugins/auth";
export const useSupportStore = defineStore("supportServiceStore", () => {
const { showLoader, hideLoader, messageError } = useCounterMixin();
const $q = useQuasar();
const openChat = ref<boolean>(false);
const icon = ref<string>("mdi-account-check");
const userId = ref<string | undefined>(keycloak.subject);
const userId = ref<string | undefined>("");
const userStatus = ref<SupportUserStatus[]>([]);
const issue = ref<SupportIssueResponse>();
const issueCategory = ref<SupportIssueCategoryResponse>();
@ -33,7 +34,7 @@ export const useSupportStore = defineStore("supportServiceStore", () => {
const scrollContainer = ref();
const socket = io(config.API.supportSocket, {
auth: { token: keycloak.token },
auth: { token: getToken() },
autoConnect: false,
path: "/api/v1/support/socket/",
});
@ -42,7 +43,9 @@ export const useSupportStore = defineStore("supportServiceStore", () => {
userStatus.value = data;
});
socket.on("online", (r) => {
socket.on("online", async (r) => {
const user = await tokenParsed();
userId.value = user?.sub;
userStatus.value.push({
socketId: r.socketId,
userId: r.userId,