QA bug fixes
This commit is contained in:
parent
311e9a75dd
commit
42eb051368
|
@ -1160,6 +1160,7 @@ App::patch('/v1/users/:userId/email')
|
||||||
|
|
||||||
$email = \strtolower($email);
|
$email = \strtolower($email);
|
||||||
|
|
||||||
|
if (\strlen($email) !== 0) {
|
||||||
// Makes sure this email is not already used in another identity
|
// Makes sure this email is not already used in another identity
|
||||||
$identityWithMatchingEmail = $dbForProject->findOne('identities', [
|
$identityWithMatchingEmail = $dbForProject->findOne('identities', [
|
||||||
Query::equal('providerEmail', [$email]),
|
Query::equal('providerEmail', [$email]),
|
||||||
|
@ -1176,6 +1177,7 @@ App::patch('/v1/users/:userId/email')
|
||||||
if ($target instanceof Document && !$target->isEmpty()) {
|
if ($target instanceof Document && !$target->isEmpty()) {
|
||||||
throw new Exception(Exception::USER_TARGET_ALREADY_EXISTS);
|
throw new Exception(Exception::USER_TARGET_ALREADY_EXISTS);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$oldEmail = $user->getAttribute('email');
|
$oldEmail = $user->getAttribute('email');
|
||||||
|
|
||||||
|
@ -1184,7 +1186,6 @@ App::patch('/v1/users/:userId/email')
|
||||||
->setAttribute('emailVerification', false)
|
->setAttribute('emailVerification', false)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$user = $dbForProject->updateDocument('users', $user->getId(), $user);
|
$user = $dbForProject->updateDocument('users', $user->getId(), $user);
|
||||||
/**
|
/**
|
||||||
|
@ -1193,7 +1194,11 @@ App::patch('/v1/users/:userId/email')
|
||||||
$oldTarget = $user->find('identifier', $oldEmail, 'targets');
|
$oldTarget = $user->find('identifier', $oldEmail, 'targets');
|
||||||
|
|
||||||
if ($oldTarget instanceof Document && !$oldTarget->isEmpty()) {
|
if ($oldTarget instanceof Document && !$oldTarget->isEmpty()) {
|
||||||
|
if (\strlen($email) !== 0) {
|
||||||
$dbForProject->updateDocument('targets', $oldTarget->getId(), $oldTarget->setAttribute('identifier', $email));
|
$dbForProject->updateDocument('targets', $oldTarget->getId(), $oldTarget->setAttribute('identifier', $email));
|
||||||
|
} else {
|
||||||
|
$dbForProject->deleteDocument('targets', $oldTarget->getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||||
} catch (Duplicate $th) {
|
} catch (Duplicate $th) {
|
||||||
|
@ -1240,6 +1245,7 @@ App::patch('/v1/users/:userId/phone')
|
||||||
->setAttribute('phoneVerification', false)
|
->setAttribute('phoneVerification', false)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if (\strlen($number) !== 0) {
|
||||||
$target = $dbForProject->findOne('targets', [
|
$target = $dbForProject->findOne('targets', [
|
||||||
Query::equal('identifier', [$number]),
|
Query::equal('identifier', [$number]),
|
||||||
]);
|
]);
|
||||||
|
@ -1247,6 +1253,7 @@ App::patch('/v1/users/:userId/phone')
|
||||||
if ($target instanceof Document && !$target->isEmpty()) {
|
if ($target instanceof Document && !$target->isEmpty()) {
|
||||||
throw new Exception(Exception::USER_TARGET_ALREADY_EXISTS);
|
throw new Exception(Exception::USER_TARGET_ALREADY_EXISTS);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$user = $dbForProject->updateDocument('users', $user->getId(), $user);
|
$user = $dbForProject->updateDocument('users', $user->getId(), $user);
|
||||||
|
@ -1256,7 +1263,11 @@ App::patch('/v1/users/:userId/phone')
|
||||||
$oldTarget = $user->find('identifier', $oldPhone, 'targets');
|
$oldTarget = $user->find('identifier', $oldPhone, 'targets');
|
||||||
|
|
||||||
if ($oldTarget instanceof Document && !$oldTarget->isEmpty()) {
|
if ($oldTarget instanceof Document && !$oldTarget->isEmpty()) {
|
||||||
|
if (\strlen($number) !== 0) {
|
||||||
$dbForProject->updateDocument('targets', $oldTarget->getId(), $oldTarget->setAttribute('identifier', $number));
|
$dbForProject->updateDocument('targets', $oldTarget->getId(), $oldTarget->setAttribute('identifier', $number));
|
||||||
|
} else {
|
||||||
|
$dbForProject->deleteDocument('targets', $oldTarget->getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||||
} catch (Duplicate $th) {
|
} catch (Duplicate $th) {
|
||||||
|
|
Loading…
Reference in a new issue