feat: update error codes in the teams API
This commit is contained in:
parent
c3369dec50
commit
7160364902
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in a new issue