feat: update error codes in the teams API

This commit is contained in:
Christy Jacob
2022-02-06 19:57:15 +04:00
parent c3369dec50
commit 7160364902
3 changed files with 8 additions and 2 deletions
+5
View File
@@ -206,6 +206,11 @@ return [
'description' => 'The membership ID does not belong to the team ID.',
'statusCode' => 404,
],
Exception::TEAM_INVITE_MISMATCH => [
'name' => Exception::TEAM_INVITE_MISMATCH,
'description' => 'The invite does not belong to the current user.',
'statusCode' => 401,
],
/** Membership */
+2 -2
View File
@@ -639,7 +639,7 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status')
}
if ($userId != $membership->getAttribute('userId')) {
throw new Exception('Invite does not belong to current user ('.$user->getAttribute('email').')', 401);
throw new Exception('Invite does not belong to current user ('.$user->getAttribute('email').')', 401, Exception::TEAM_INVITE_MISMATCH);
}
if ($user->isEmpty()) {
@@ -647,7 +647,7 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status')
}
if ($membership->getAttribute('userId') !== $user->getId()) {
throw new Exception('Invite does not belong to current user ('.$user->getAttribute('email').')', 401);
throw new Exception('Invite does not belong to current user ('.$user->getAttribute('email').')', 401, Exception::TEAM_INVITE_MISMATCH);
}
$membership // Attach user to team
+1
View File
@@ -59,6 +59,7 @@ class Exception extends \Exception
const TEAM_INVITE_NOT_FOUND = 'team_invite_not_found';
const TEAM_INVALID_SECRET = 'team_invalid_secret';
const TEAM_MEMBERSHIP_MISMATCH = 'team_membership_mismatch';
const TEAM_INVITE_MISMATCH = 'team_invite_mismatch';
/** Membership */
const MEMBERSHIP_NOT_FOUND = 'membership_not_found';