From 962e3395e011521a1a6b90340bb33296d62fcd95 Mon Sep 17 00:00:00 2001 From: Anthony Kinsey Date: Thu, 10 Feb 2022 15:05:40 -1000 Subject: [PATCH] fix: issue with getting 401 when checking is user is logged in --- src/components/polls/PollViewer.vue | 7 ++++--- src/views/Join.vue | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/polls/PollViewer.vue b/src/components/polls/PollViewer.vue index 13335a9f..33859fa4 100644 --- a/src/components/polls/PollViewer.vue +++ b/src/components/polls/PollViewer.vue @@ -146,7 +146,7 @@ export default { }) } const votingEligible = () => { - if (!$auth.loggedIn) { return false } + if (!v.loggedIn) { return false } else if (props.bannedFromBoard) { return false } else if (!v.permissionUtils.hasPermission('threads.vote.allow')) { return false } else if (v.pollCopy.locked) { return false } @@ -155,7 +155,7 @@ export default { } /* View Methods */ const canLock = () => { - if (!$auth.loggedIn) { return false } + if (!v.loggedIn) { return false } if (props.bannedFromBoard) { return false } if (!v.permissionUtils.hasPermission('threads.lockPoll.allow')) { return false } @@ -169,7 +169,7 @@ export default { else return false } const canEdit = () => { - if (!$auth.loggedIn) { return false } + if (!v.loggedIn) { return false } if (props.bannedFromBoard) { return false } if (!v.permissionUtils.hasPermission('threads.editPoll.allow')) { return false } @@ -296,6 +296,7 @@ export default { /* View Data */ const v = reactive({ + loggedIn: $auth.loggedIn, permissionUtils: $auth.permissionUtils, options: { expiration: props.poll.expiration || undefined, diff --git a/src/views/Join.vue b/src/views/Join.vue index 06556397..f2840421 100644 --- a/src/views/Join.vue +++ b/src/views/Join.vue @@ -133,8 +133,6 @@ export default { const $route = useRoute() const $router = useRouter() - if ($auth.loggedIn) $auth.logout() // If user is currently logged in for some reason, log them out - /* Template Data */ const initForm = { valid: false, @@ -149,11 +147,16 @@ export default { } const v = reactive({ + loggedIn: $auth.loggedIn, form: cloneDeep(initForm), focusInput: null, showRegisterHideConfirm: true }) + if (v.loggedIn) $auth.logout() // If user is currently logged in for some reason, log them out + + watch(() => v.focusInput, f => f ? v.focusInput.focus() : null) + /* Watch Data */ watch(() => v.form.email.val, debounce(async (val) => { v.form.email.valid = val && val.length >= 3 && emailRegex.test(val)