Skip to content

FOUR-25299 | Improve Error Handling for Missing API Token #8369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: epic/FOUR-22519
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion ProcessMaker/Http/Controllers/Api/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,20 @@ public function update(User $user, Request $request)
$user->meta = null;
}

$user->saveOrFail();
try {
$user->saveOrFail();
} catch (\Exception $e) {
$slackExceptionClass = 'ProcessMaker\Packages\Connectors\Slack\Exceptions\SlackConfigurationException';

if (class_exists($slackExceptionClass) && $e instanceof $slackExceptionClass) {
return response([
'message' => $e->getMessage(),
], 422);
}

throw $e;
}

$changes = $user->getChanges();

//Call new Event to store User Changes into LOG
Expand Down
8 changes: 5 additions & 3 deletions resources/views/profile/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
if (error.response?.data?.message?.includes('Slack')) {
ProcessMaker.alert(this.$t(error.response.data.message), 'danger');
// Need to ensure the slack toggle is now disabled in the ui
this.handleConnectedAccountToggle(DEFAULT_ACCOUNTS.connectorSlack, false);
this.handleConnectedAccountToggle(DEFAULT_ACCOUNTS.connectorSlack, false, true);
}
});

Expand All @@ -288,7 +288,7 @@
checkEmailChange() {
this.emailHasChanged = this.formData.email !== this.originalEmail;
},
handleConnectedAccountToggle(account, $event) {
handleConnectedAccountToggle(account, $event, error) {
try {
let accounts = [];
if (this.formData.connected_accounts) {
Expand Down Expand Up @@ -320,7 +320,9 @@
JSON.parse(jsonString);

this.formData.connected_accounts = jsonString;
this.saveProfileChanges();
if(!error) {
this.saveProfileChanges();
}
} catch (error) {
console.error('Error handling connected account toggle:', error);
ProcessMaker.alert(this.$t('Error updating connected account'), 'danger');
Expand Down
Loading