diff --git a/app/controllers/google/callbacks_controller.rb b/app/controllers/google/callbacks_controller.rb index 391e1de0f..766d984df 100644 --- a/app/controllers/google/callbacks_controller.rb +++ b/app/controllers/google/callbacks_controller.rb @@ -1,6 +1,15 @@ class Google::CallbacksController < OauthCallbackController include GoogleConcern + def find_channel_by_email + # find by imap_login first, and then by email + # this ensures the legacy users can migrate correctly even if inbox email address doesn't match + imap_channel = Channel::Email.find_by(imap_login: users_data['email'], account: account) + return imap_channel if imap_channel + + Channel::Email.find_by(email: users_data['email'], account: account) + end + private def provider_name diff --git a/app/controllers/oauth_callback_controller.rb b/app/controllers/oauth_callback_controller.rb index 309160f1f..4cb02d266 100644 --- a/app/controllers/oauth_callback_controller.rb +++ b/app/controllers/oauth_callback_controller.rb @@ -25,7 +25,7 @@ class OauthCallbackController < ApplicationController end def find_or_create_inbox - channel_email = Channel::Email.find_by(email: users_data['email'], account: account) + channel_email = find_channel_by_email # we need this value to know where to redirect on sucessful processing of the callback channel_exists = channel_email.present? @@ -39,6 +39,10 @@ class OauthCallbackController < ApplicationController [channel_email.inbox, channel_exists] end + def find_channel_by_email + Channel::Email.find_by(email: users_data['email'], account: account) + end + def update_channel(channel_email) channel_email.update!({ imap_login: users_data['email'], imap_address: imap_address, diff --git a/app/javascript/dashboard/App.vue b/app/javascript/dashboard/App.vue index 977f8565c..c32cb98d2 100644 --- a/app/javascript/dashboard/App.vue +++ b/app/javascript/dashboard/App.vue @@ -13,6 +13,7 @@ import { useStore } from 'dashboard/composables/store'; import WootSnackbarBox from './components/SnackbarContainer.vue'; import { setColorTheme } from './helper/themeHelper'; import { isOnOnboardingView } from 'v3/helpers/RouteHelper'; +import { useAccount } from 'dashboard/composables/useAccount'; import { registerSubscription, verifyServiceWorkerExistence, @@ -35,8 +36,9 @@ export default { setup() { const router = useRouter(); const store = useStore(); + const { accountId } = useAccount(); - return { router, store }; + return { router, store, currentAccountId: accountId }; }, data() { return { @@ -52,7 +54,6 @@ export default { currentUser: 'getCurrentUser', authUIFlags: 'getAuthUIFlags', accountUIFlags: 'accounts/getUIFlags', - currentAccountId: 'getCurrentAccountId', }), hasAccounts() { const { accounts = [] } = this.currentUser || {}; @@ -69,10 +70,13 @@ export default { this.showAddAccountModal = true; } }, - currentAccountId() { - if (this.currentAccountId) { - this.initializeAccount(); - } + currentAccountId: { + immediate: true, + handler() { + if (this.currentAccountId) { + this.initializeAccount(); + } + }, }, }, mounted() { diff --git a/app/javascript/dashboard/components/layout/Sidebar.vue b/app/javascript/dashboard/components/layout/Sidebar.vue index a08b99a2b..81539c1bb 100644 --- a/app/javascript/dashboard/components/layout/Sidebar.vue +++ b/app/javascript/dashboard/components/layout/Sidebar.vue @@ -2,6 +2,7 @@ import { mapGetters } from 'vuex'; import { getSidebarItems } from './config/default-sidebar'; import { useKeyboardEvents } from 'dashboard/composables/useKeyboardEvents'; +import { useAccount } from 'dashboard/composables/useAccount'; import { useRoute, useRouter } from 'vue-router'; import PrimarySidebar from './sidebarComponents/Primary.vue'; @@ -33,6 +34,7 @@ export default { setup(props, { emit }) { const route = useRoute(); const router = useRouter(); + const { accountId } = useAccount(); const toggleKeyShortcutModal = () => { emit('openKeyShortcutModal'); @@ -72,6 +74,7 @@ export default { return { toggleKeyShortcutModal, + accountId, }; }, data() { @@ -82,7 +85,6 @@ export default { computed: { ...mapGetters({ - accountId: 'getCurrentAccountId', currentUser: 'getCurrentUser', globalConfig: 'globalConfig/get', inboxes: 'inboxes/getInboxes', diff --git a/app/javascript/dashboard/components/widgets/conversation/bubble/Text.vue b/app/javascript/dashboard/components/widgets/conversation/bubble/Text.vue index 8d9abb1a5..6500cbc35 100644 --- a/app/javascript/dashboard/components/widgets/conversation/bubble/Text.vue +++ b/app/javascript/dashboard/components/widgets/conversation/bubble/Text.vue @@ -1,5 +1,5 @@ diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/google/Reauthorize.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/google/Reauthorize.vue index bc4df68d1..de9047ca7 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/google/Reauthorize.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/google/Reauthorize.vue @@ -1,5 +1,5 @@