Skip to content
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"smarty/smarty": "^5.8.4",
"sendgrid/sendgrid": "^8.1",
"google/cloud-logging": "1.28.*",
"auth0/auth0-php": "^8.0.5",
"auth0/auth0-php": "^9.2.0",
"opencensus/opencensus": "^0.7.0",
"kriswallsmith/buzz": "^1.4",
"nyholm/psr7": "^1.4",
Expand Down
69 changes: 37 additions & 32 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 8 additions & 13 deletions include/cms_users_edit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Auth0\SDK\Utility\HttpResponse;
use Auth0\SDK\API\Management\Users\Requests\ListUsersByEmailRequestParameters;

$table = 'cms_users';

Expand Down Expand Up @@ -51,18 +51,13 @@
// check auth0 if an email addrress is already created but with different id
global $settings;
$mgmtAPI = getAuth0Management($settings);
$authUser = $mgmtAPI->usersByEmail()->get($_POST['email']);

if (HttpResponse::wasSuccessful($authUser)) {
$authUser = HttpResponse::decodeContent($authUser);
if ($authUser && $authUser[0]['blocked']) {
redirect('?action=cms_users_edit&origin='.$_POST['_origin'].'&warning=1&message=This email already exists in the system. Please use a different email to create a new user!');
trigger_error('This email already exists in the system. Please use a different email to create a new user!', E_USER_NOTICE);
} elseif (!$existinguser && $authUser && !$authUser[0]['blocked']) {
throw new Exception('The user already exists in AUTH0 but its not sync', 409);
}
} else {
throw new Exception($authUser->getReasonPhrase(), $authUser->getStatusCode());
// auth0-php 9 returns typed objects and throws an Auth0ApiException on non-2XX responses
$authUser = auth0ToArray($mgmtAPI->users->listUsersByEmail(new ListUsersByEmailRequestParameters(['email' => $_POST['email']])) ?? []);
if ($authUser && !empty($authUser[0]['blocked'])) {
redirect('?action=cms_users_edit&origin='.$_POST['_origin'].'&warning=1&message=This email already exists in the system. Please use a different email to create a new user!');
trigger_error('This email already exists in the system. Please use a different email to create a new user!', E_USER_NOTICE);
} elseif (!$existinguser && $authUser && empty($authUser[0]['blocked'])) {
throw new Exception('The user already exists in AUTH0 but its not sync', 409);
}

// Validate if user can access this user account
Expand Down
Loading