Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97671f3dc0 | ||
|
|
f18ed01eb7 | ||
|
|
aa5fa0c758 | ||
|
|
42eca69763 | ||
|
|
3a78192e74 | ||
|
|
02894ba221 | ||
|
|
1c3f6f46fe |
@@ -1,6 +1,15 @@
|
|||||||
class Google::CallbacksController < OauthCallbackController
|
class Google::CallbacksController < OauthCallbackController
|
||||||
include GoogleConcern
|
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
|
private
|
||||||
|
|
||||||
def provider_name
|
def provider_name
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class OauthCallbackController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def find_or_create_inbox
|
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
|
# we need this value to know where to redirect on sucessful processing of the callback
|
||||||
channel_exists = channel_email.present?
|
channel_exists = channel_email.present?
|
||||||
|
|
||||||
@@ -39,6 +39,10 @@ class OauthCallbackController < ApplicationController
|
|||||||
[channel_email.inbox, channel_exists]
|
[channel_email.inbox, channel_exists]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_channel_by_email
|
||||||
|
Channel::Email.find_by(email: users_data['email'], account: account)
|
||||||
|
end
|
||||||
|
|
||||||
def update_channel(channel_email)
|
def update_channel(channel_email)
|
||||||
channel_email.update!({
|
channel_email.update!({
|
||||||
imap_login: users_data['email'], imap_address: imap_address,
|
imap_login: users_data['email'], imap_address: imap_address,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { useStore } from 'dashboard/composables/store';
|
|||||||
import WootSnackbarBox from './components/SnackbarContainer.vue';
|
import WootSnackbarBox from './components/SnackbarContainer.vue';
|
||||||
import { setColorTheme } from './helper/themeHelper';
|
import { setColorTheme } from './helper/themeHelper';
|
||||||
import { isOnOnboardingView } from 'v3/helpers/RouteHelper';
|
import { isOnOnboardingView } from 'v3/helpers/RouteHelper';
|
||||||
|
import { useAccount } from 'dashboard/composables/useAccount';
|
||||||
import {
|
import {
|
||||||
registerSubscription,
|
registerSubscription,
|
||||||
verifyServiceWorkerExistence,
|
verifyServiceWorkerExistence,
|
||||||
@@ -35,8 +36,9 @@ export default {
|
|||||||
setup() {
|
setup() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
const { accountId } = useAccount();
|
||||||
|
|
||||||
return { router, store };
|
return { router, store, currentAccountId: accountId };
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -52,7 +54,6 @@ export default {
|
|||||||
currentUser: 'getCurrentUser',
|
currentUser: 'getCurrentUser',
|
||||||
authUIFlags: 'getAuthUIFlags',
|
authUIFlags: 'getAuthUIFlags',
|
||||||
accountUIFlags: 'accounts/getUIFlags',
|
accountUIFlags: 'accounts/getUIFlags',
|
||||||
currentAccountId: 'getCurrentAccountId',
|
|
||||||
}),
|
}),
|
||||||
hasAccounts() {
|
hasAccounts() {
|
||||||
const { accounts = [] } = this.currentUser || {};
|
const { accounts = [] } = this.currentUser || {};
|
||||||
@@ -69,10 +70,13 @@ export default {
|
|||||||
this.showAddAccountModal = true;
|
this.showAddAccountModal = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
currentAccountId() {
|
currentAccountId: {
|
||||||
if (this.currentAccountId) {
|
immediate: true,
|
||||||
this.initializeAccount();
|
handler() {
|
||||||
}
|
if (this.currentAccountId) {
|
||||||
|
this.initializeAccount();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import { getSidebarItems } from './config/default-sidebar';
|
import { getSidebarItems } from './config/default-sidebar';
|
||||||
import { useKeyboardEvents } from 'dashboard/composables/useKeyboardEvents';
|
import { useKeyboardEvents } from 'dashboard/composables/useKeyboardEvents';
|
||||||
|
import { useAccount } from 'dashboard/composables/useAccount';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
import PrimarySidebar from './sidebarComponents/Primary.vue';
|
import PrimarySidebar from './sidebarComponents/Primary.vue';
|
||||||
@@ -33,6 +34,7 @@ export default {
|
|||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const { accountId } = useAccount();
|
||||||
|
|
||||||
const toggleKeyShortcutModal = () => {
|
const toggleKeyShortcutModal = () => {
|
||||||
emit('openKeyShortcutModal');
|
emit('openKeyShortcutModal');
|
||||||
@@ -72,6 +74,7 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
toggleKeyShortcutModal,
|
toggleKeyShortcutModal,
|
||||||
|
accountId,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -82,7 +85,6 @@ export default {
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
accountId: 'getCurrentAccountId',
|
|
||||||
currentUser: 'getCurrentUser',
|
currentUser: 'getCurrentUser',
|
||||||
globalConfig: 'globalConfig/get',
|
globalConfig: 'globalConfig/get',
|
||||||
inboxes: 'inboxes/getInboxes',
|
inboxes: 'inboxes/getInboxes',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import Letter from 'vue-letter';
|
import { Letter } from 'vue-letter';
|
||||||
import GalleryView from '../components/GalleryView.vue';
|
import GalleryView from '../components/GalleryView.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
import { ref } from 'vue';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
import { describe, it, expect, vi } from 'vitest';
|
|
||||||
import { useAccount } from '../useAccount';
|
import { useAccount } from '../useAccount';
|
||||||
import { useStoreGetters } from 'dashboard/composables/store';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
vi.mock('dashboard/composables/store');
|
vi.mock('vue-router');
|
||||||
|
|
||||||
describe('useAccount', () => {
|
describe('useAccount', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
useStoreGetters.mockReturnValue({
|
useRoute.mockReturnValue({
|
||||||
getCurrentAccountId: ref(123),
|
params: {
|
||||||
|
accountId: 123,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useStoreGetters } from 'dashboard/composables/store';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composable for account-related operations.
|
* Composable for account-related operations.
|
||||||
* @returns {Object} An object containing account-related properties and methods.
|
* @returns {Object} An object containing account-related properties and methods.
|
||||||
*/
|
*/
|
||||||
export function useAccount() {
|
export function useAccount() {
|
||||||
const getters = useStoreGetters();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computed property for the current account ID.
|
* Computed property for the current account ID.
|
||||||
* @type {import('vue').ComputedRef<number>}
|
* @type {import('vue').ComputedRef<number>}
|
||||||
*/
|
*/
|
||||||
const accountId = computed(() => getters.getCurrentAccountId.value);
|
const route = useRoute();
|
||||||
|
|
||||||
|
const accountId = computed(() => {
|
||||||
|
return Number(route.params.accountId);
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates an account-scoped URL.
|
* Generates an account-scoped URL.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { mapGetters } from 'vuex';
|
|||||||
import { useAlert } from 'dashboard/composables';
|
import { useAlert } from 'dashboard/composables';
|
||||||
import { useUISettings } from 'dashboard/composables/useUISettings';
|
import { useUISettings } from 'dashboard/composables/useUISettings';
|
||||||
import { useConfig } from 'dashboard/composables/useConfig';
|
import { useConfig } from 'dashboard/composables/useConfig';
|
||||||
|
import { useAccount } from 'dashboard/composables/useAccount';
|
||||||
import { FEATURE_FLAGS } from '../../../../featureFlags';
|
import { FEATURE_FLAGS } from '../../../../featureFlags';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import { getLanguageDirection } from 'dashboard/components/widgets/conversation/advancedFilterItems/languages';
|
import { getLanguageDirection } from 'dashboard/components/widgets/conversation/advancedFilterItems/languages';
|
||||||
@@ -13,9 +14,10 @@ export default {
|
|||||||
setup() {
|
setup() {
|
||||||
const { updateUISettings } = useUISettings();
|
const { updateUISettings } = useUISettings();
|
||||||
const { enabledLanguages } = useConfig();
|
const { enabledLanguages } = useConfig();
|
||||||
|
const { accountId } = useAccount();
|
||||||
const v$ = useVuelidate();
|
const v$ = useVuelidate();
|
||||||
|
|
||||||
return { updateUISettings, v$, enabledLanguages };
|
return { updateUISettings, v$, enabledLanguages, accountId };
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -46,7 +48,6 @@ export default {
|
|||||||
globalConfig: 'globalConfig/get',
|
globalConfig: 'globalConfig/get',
|
||||||
getAccount: 'accounts/getAccount',
|
getAccount: 'accounts/getAccount',
|
||||||
uiFlags: 'accounts/getUIFlags',
|
uiFlags: 'accounts/getUIFlags',
|
||||||
accountId: 'getCurrentAccountId',
|
|
||||||
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
|
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
|
||||||
}),
|
}),
|
||||||
showAutoResolutionConfig() {
|
showAutoResolutionConfig() {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const emailProviderList = computed(() => {
|
|||||||
|
|
||||||
function onClick(emailProvider) {
|
function onClick(emailProvider) {
|
||||||
if (emailProvider.isEnabled) {
|
if (emailProvider.isEnabled) {
|
||||||
this.provider = emailProvider.key;
|
provider.value = emailProvider.key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+9
-2
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import InboxReconnectionRequired from '../../components/InboxReconnectionRequired.vue';
|
import InboxReconnectionRequired from '../../components/InboxReconnectionRequired.vue';
|
||||||
import googleClient from 'dashboard/api/channel/googleClient';
|
import googleClient from 'dashboard/api/channel/googleClient';
|
||||||
|
|
||||||
@@ -17,11 +17,18 @@ const { t } = useI18n();
|
|||||||
|
|
||||||
const isRequestingAuthorization = ref(false);
|
const isRequestingAuthorization = ref(false);
|
||||||
|
|
||||||
|
const inboxEmail = computed(() => {
|
||||||
|
if (props.inbox.imap_login && props.inbox.imap_enabled) {
|
||||||
|
return props.inbox.imap_login;
|
||||||
|
}
|
||||||
|
return props.inbox.email;
|
||||||
|
});
|
||||||
|
|
||||||
async function requestAuthorization() {
|
async function requestAuthorization() {
|
||||||
try {
|
try {
|
||||||
isRequestingAuthorization.value = true;
|
isRequestingAuthorization.value = true;
|
||||||
const response = await googleClient.generateAuthorization({
|
const response = await googleClient.generateAuthorization({
|
||||||
email: props.inbox.email,
|
email: inboxEmail.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import Multiselect from 'vue-multiselect';
|
|||||||
import { plugin, defaultConfig } from '@formkit/vue';
|
import { plugin, defaultConfig } from '@formkit/vue';
|
||||||
import WootSwitch from 'components/ui/Switch.vue';
|
import WootSwitch from 'components/ui/Switch.vue';
|
||||||
import WootWizard from 'components/ui/Wizard.vue';
|
import WootWizard from 'components/ui/Wizard.vue';
|
||||||
import { sync } from 'vuex-router-sync';
|
|
||||||
import FloatingVue from 'floating-vue';
|
import FloatingVue from 'floating-vue';
|
||||||
import WootUiKit from 'dashboard/components';
|
import WootUiKit from 'dashboard/components';
|
||||||
import App from 'dashboard/App.vue';
|
import App from 'dashboard/App.vue';
|
||||||
@@ -18,6 +17,7 @@ import i18nMessages from 'dashboard/i18n';
|
|||||||
import createAxios from 'dashboard/helper/APIHelper';
|
import createAxios from 'dashboard/helper/APIHelper';
|
||||||
|
|
||||||
import commonHelpers, { isJSONValid } from 'dashboard/helper/commons';
|
import commonHelpers, { isJSONValid } from 'dashboard/helper/commons';
|
||||||
|
import { sync } from 'vuex-router-sync';
|
||||||
import router, { initalizeRouter } from 'dashboard/routes';
|
import router, { initalizeRouter } from 'dashboard/routes';
|
||||||
import store from 'dashboard/store';
|
import store from 'dashboard/store';
|
||||||
import constants from 'dashboard/constants/globals';
|
import constants from 'dashboard/constants/globals';
|
||||||
@@ -42,6 +42,8 @@ const i18n = createI18n({
|
|||||||
messages: i18nMessages,
|
messages: i18nMessages,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
sync(store, router);
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
app.use(i18n);
|
app.use(i18n);
|
||||||
app.use(store);
|
app.use(store);
|
||||||
@@ -97,7 +99,6 @@ app.component('fluent-icon', FluentIcon);
|
|||||||
app.directive('resize', vResizeObserver);
|
app.directive('resize', vResizeObserver);
|
||||||
app.directive('on-clickaway', onClickaway);
|
app.directive('on-clickaway', onClickaway);
|
||||||
|
|
||||||
sync(store, router);
|
|
||||||
// load common helpers into js
|
// load common helpers into js
|
||||||
commonHelpers();
|
commonHelpers();
|
||||||
window.WOOT_STORE = store;
|
window.WOOT_STORE = store;
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ export default createRouter({
|
|||||||
component: () => import('./views/Messages.vue'),
|
component: () => import('./views/Messages.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/article',
|
path: '/article/:link',
|
||||||
name: 'article-viewer',
|
name: 'article-viewer',
|
||||||
|
props: true,
|
||||||
component: () => import('./views/ArticleViewer.vue'),
|
component: () => import('./views/ArticleViewer.vue'),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
<script>
|
<script setup>
|
||||||
import IframeLoader from 'shared/components/IframeLoader.vue';
|
import IframeLoader from 'shared/components/IframeLoader.vue';
|
||||||
|
|
||||||
export default {
|
defineProps({
|
||||||
name: 'ArticleViewer',
|
link: {
|
||||||
components: {
|
type: String,
|
||||||
IframeLoader,
|
required: true,
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="bg-white h-full">
|
<div class="bg-white h-full">
|
||||||
<IframeLoader :url="$route.query.link" />
|
<IframeLoader :url="link" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export default {
|
|||||||
}
|
}
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: 'article-viewer',
|
name: 'article-viewer',
|
||||||
query: { link: linkToOpen },
|
params: { link: linkToOpen },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
viewAllArticles() {
|
viewAllArticles() {
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ RSpec.describe 'Google::CallbacksController', type: :request do
|
|||||||
expect(Redis::Alfred.get(cache_key)).to be_nil
|
expect(Redis::Alfred.get(cache_key)).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates updates inbox channel config if inbox exists and authentication is successful' do
|
it 'updates inbox channel config if inbox exists with imap_login and authentication is successful' do
|
||||||
inbox = create(:channel_email, account: account, email: email)&.inbox
|
channel_email = create(:channel_email, account: account, imap_login: email)
|
||||||
|
inbox = channel_email.inbox
|
||||||
expect(inbox.channel.provider_config).to eq({})
|
expect(inbox.channel.provider_config).to eq({})
|
||||||
|
|
||||||
stub_request(:post, 'https://accounts.google.com/o/oauth2/token')
|
stub_request(:post, 'https://accounts.google.com/o/oauth2/token')
|
||||||
@@ -50,7 +51,7 @@ RSpec.describe 'Google::CallbacksController', type: :request do
|
|||||||
|
|
||||||
get google_callback_url, params: { code: code }
|
get google_callback_url, params: { code: code }
|
||||||
|
|
||||||
expect(response).to redirect_to app_email_inbox_settings_url(account_id: account.id, inbox_id: account.inboxes.last.id)
|
expect(response).to redirect_to app_email_inbox_settings_url(account_id: account.id, inbox_id: inbox.id)
|
||||||
expect(account.inboxes.count).to be 1
|
expect(account.inboxes.count).to be 1
|
||||||
expect(inbox.channel.reload.provider_config.keys).to include('access_token', 'refresh_token', 'expires_on')
|
expect(inbox.channel.reload.provider_config.keys).to include('access_token', 'refresh_token', 'expires_on')
|
||||||
expect(inbox.channel.reload.provider_config['access_token']).to eq response_body_success[:access_token]
|
expect(inbox.channel.reload.provider_config['access_token']).to eq response_body_success[:access_token]
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ export default defineConfig({
|
|||||||
lib: isLibraryMode
|
lib: isLibraryMode
|
||||||
? {
|
? {
|
||||||
entry: path.resolve(__dirname, './app/javascript/entrypoints/sdk.js'),
|
entry: path.resolve(__dirname, './app/javascript/entrypoints/sdk.js'),
|
||||||
formats: ['umd'], // UMD format for single file
|
formats: ['cjs'], // CJS format for single file
|
||||||
name: 'sdk',
|
name: 'sdk',
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user