Merge branch 'develop' into feat/setup-eslint-rules

This commit is contained in:
Sivin Varghese
2024-08-02 14:23:56 +05:30
committed by GitHub
3 changed files with 25 additions and 20 deletions
@@ -8,7 +8,9 @@ class Api::V1::Accounts::Integrations::CaptainController < Api::V1::Accounts::Ba
"&email=#{URI.encode_www_form_component(@hook['settings']['account_email'])}" \
"&account_id=#{URI.encode_www_form_component(@hook['settings']['account_id'])}"
sso_url = "#{ENV.fetch('CAPTAIN_APP_URL', '')}/sso?#{params_string}"
installation_config = InstallationConfig.find_by(name: 'CAPTAIN_APP_URL')
sso_url = "#{installation_config.value}/sso?#{params_string}"
render json: { sso_url: sso_url }, status: :ok
end
+9 -6
View File
@@ -105,11 +105,6 @@ export default {
useAlert(this.loginApi.message);
},
submitLogin() {
if (this.v$.credentials.email.$invalid && !this.email) {
this.showAlertMessage(this.$t('LOGIN.EMAIL.ERROR'));
return;
}
this.loginApi.hasErrored = false;
this.loginApi.showLoading = true;
@@ -138,6 +133,14 @@ export default {
);
});
},
submitFormLogin() {
if (this.v$.credentials.email.$invalid && !this.email) {
this.showAlertMessage(this.$t('LOGIN.EMAIL.ERROR'));
return;
}
this.submitLogin();
},
},
};
</script>
@@ -184,7 +187,7 @@ export default {
>
<div v-if="!email">
<GoogleOAuthButton v-if="showGoogleOAuth" />
<form class="space-y-5" @submit.prevent="submitLogin">
<form class="space-y-5" @submit.prevent="submitFormLogin">
<FormInput
v-model.trim="credentials.email"
name="email_address"
@@ -37,6 +37,8 @@ RSpec.describe 'Captain Integrations API', type: :request do
end
it 'returns sso url if hook is available' do
InstallationConfig.where(name: 'CAPTAIN_APP_URL').first_or_create(value: 'https://app.chatwoot.com')
hook = create(:integrations_hook, account: account, app_id: 'captain', settings: {
access_token: SecureRandom.hex,
account_email: Faker::Internet.email,
@@ -45,21 +47,19 @@ RSpec.describe 'Captain Integrations API', type: :request do
inbox_ids: '1'
})
with_modified_env CAPTAIN_APP_URL: 'https://app.example.com' do
get sso_url_api_v1_account_integrations_captain_url(account_id: account.id),
params: {},
headers: admin.create_new_auth_token,
as: :json
get sso_url_api_v1_account_integrations_captain_url(account_id: account.id),
params: {},
headers: admin.create_new_auth_token,
as: :json
expect(response).to have_http_status(:success)
data = response.parsed_body
params_string = "token=#{URI.encode_www_form_component(hook['settings']['access_token'])}" \
"&email=#{URI.encode_www_form_component(hook['settings']['account_email'])}" \
"&account_id=#{URI.encode_www_form_component(hook['settings']['account_id'])}"
expect(response).to have_http_status(:success)
data = response.parsed_body
params_string = "token=#{URI.encode_www_form_component(hook['settings']['access_token'])}" \
"&email=#{URI.encode_www_form_component(hook['settings']['account_email'])}" \
"&account_id=#{URI.encode_www_form_component(hook['settings']['account_id'])}"
sso_url = "https://app.example.com/sso?#{params_string}"
expect(data['sso_url']).to eq(sso_url)
end
sso_url = "https://app.chatwoot.com/sso?#{params_string}"
expect(data['sso_url']).to eq(sso_url)
end
end
end