chore: Add better error messages for Facebook unauthorized (#7936)
This commit is contained in:
@@ -371,6 +371,8 @@
|
|||||||
"DETAILS": {
|
"DETAILS": {
|
||||||
"LOADING_FB": "Authenticating you with Facebook...",
|
"LOADING_FB": "Authenticating you with Facebook...",
|
||||||
"ERROR_FB_AUTH": "Something went wrong, Please refresh page...",
|
"ERROR_FB_AUTH": "Something went wrong, Please refresh page...",
|
||||||
|
"ERROR_FB_UNAUTHORIZED": "You're not authorized to perform this action. ",
|
||||||
|
"ERROR_FB_UNAUTHORIZED_HELP": "Please ensure you have access to the Facebook page with full control. You can read more about Facebook roles <a href=\" https://www.facebook.com/help/187316341316631\">here</a>.",
|
||||||
"CREATING_CHANNEL": "Creating your Inbox...",
|
"CREATING_CHANNEL": "Creating your Inbox...",
|
||||||
"TITLE": "Configure Inbox Details",
|
"TITLE": "Configure Inbox Details",
|
||||||
"DESC": ""
|
"DESC": ""
|
||||||
|
|||||||
@@ -17,9 +17,16 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<loading-state v-if="showLoader" :message="emptyStateMessage" />
|
<div v-if="hasError" class="max-w-lg mx-auto text-center">
|
||||||
|
<h5>{{ errorStateMessage }}</h5>
|
||||||
|
<p
|
||||||
|
v-if="errorStateDescription"
|
||||||
|
v-dompurify-html="errorStateDescription"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<loading-state v-else-if="showLoader" :message="emptyStateMessage" />
|
||||||
<form
|
<form
|
||||||
v-if="!showLoader"
|
v-else
|
||||||
class="mx-0 flex flex-wrap"
|
class="mx-0 flex flex-wrap"
|
||||||
@submit.prevent="createChannel()"
|
@submit.prevent="createChannel()"
|
||||||
>
|
>
|
||||||
@@ -99,6 +106,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isCreating: false,
|
isCreating: false,
|
||||||
|
hasError: false,
|
||||||
omniauth_token: '',
|
omniauth_token: '',
|
||||||
user_access_token: '',
|
user_access_token: '',
|
||||||
channel: 'facebook',
|
channel: 'facebook',
|
||||||
@@ -106,6 +114,8 @@ export default {
|
|||||||
pageName: '',
|
pageName: '',
|
||||||
pageList: [],
|
pageList: [],
|
||||||
emptyStateMessage: this.$t('INBOX_MGMT.DETAILS.LOADING_FB'),
|
emptyStateMessage: this.$t('INBOX_MGMT.DETAILS.LOADING_FB'),
|
||||||
|
errorStateMessage: '',
|
||||||
|
errorStateDescription: '',
|
||||||
hasLoginStarted: false,
|
hasLoginStarted: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -194,19 +204,30 @@ export default {
|
|||||||
tryFBlogin() {
|
tryFBlogin() {
|
||||||
FB.login(
|
FB.login(
|
||||||
response => {
|
response => {
|
||||||
|
this.hasError = false;
|
||||||
if (response.status === 'connected') {
|
if (response.status === 'connected') {
|
||||||
this.fetchPages(response.authResponse.accessToken);
|
this.fetchPages(response.authResponse.accessToken);
|
||||||
} else if (response.status === 'not_authorized') {
|
} else if (response.status === 'not_authorized') {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error('FACEBOOK AUTH ERROR', response);
|
||||||
|
this.hasError = true;
|
||||||
// The person is logged into Facebook, but not your app.
|
// The person is logged into Facebook, but not your app.
|
||||||
this.emptyStateMessage = this.$t(
|
this.errorStateMessage = this.$t(
|
||||||
'INBOX_MGMT.DETAILS.ERROR_FB_AUTH'
|
'INBOX_MGMT.DETAILS.ERROR_FB_UNAUTHORIZED'
|
||||||
|
);
|
||||||
|
this.errorStateDescription = this.$t(
|
||||||
|
'INBOX_MGMT.DETAILS.ERROR_FB_UNAUTHORIZED_HELP'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error('FACEBOOK AUTH ERROR', response);
|
||||||
|
this.hasError = true;
|
||||||
// The person is not logged into Facebook, so we're not sure if
|
// The person is not logged into Facebook, so we're not sure if
|
||||||
// they are logged into this app or not.
|
// they are logged into this app or not.
|
||||||
this.emptyStateMessage = this.$t(
|
this.errorStateMessage = this.$t(
|
||||||
'INBOX_MGMT.DETAILS.ERROR_FB_AUTH'
|
'INBOX_MGMT.DETAILS.ERROR_FB_AUTH'
|
||||||
);
|
);
|
||||||
|
this.errorStateDescription = '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class Instagram::MessageText < Instagram::WebhooksBaseService
|
|||||||
@inbox.channel.authorization_error!
|
@inbox.channel.authorization_error!
|
||||||
ChatwootExceptionTracker.new(e, account: @inbox.account).capture_exception
|
ChatwootExceptionTracker.new(e, account: @inbox.account).capture_exception
|
||||||
rescue StandardError, Koala::Facebook::ClientError => e
|
rescue StandardError, Koala::Facebook::ClientError => e
|
||||||
|
Rails.logger.warn("[FacebookUserFetchClientError]: #{e.message}")
|
||||||
ChatwootExceptionTracker.new(e, account: @inbox.account).capture_exception
|
ChatwootExceptionTracker.new(e, account: @inbox.account).capture_exception
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user