1
0
Fork 0
mirror of synced 2024-06-17 10:14:50 +12:00

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

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 */

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

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';