Skip to content

Commit

Permalink
Merge pull request #2620 from appwrite/fix-consistent-users-limit
Browse files Browse the repository at this point in the history
Fixed missing users limit validation
  • Loading branch information
eldadfux committed Jan 16, 2022
2 parents 33c9c5c + 9650f37 commit 464db81
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -32,7 +32,7 @@ ENV DEBUG=$DEBUG
ENV PHP_REDIS_VERSION=5.3.5 \
PHP_MONGODB_VERSION=1.9.1 \
PHP_SWOOLE_VERSION=v4.8.5 \
PHP_IMAGICK_VERSION=3.5.1 \
PHP_IMAGICK_VERSION=3.7.0 \
PHP_YAML_VERSION=2.2.2 \
PHP_MAXMINDDB_VERSION=v1.11.0

Expand Down
2 changes: 2 additions & 0 deletions app/config/collections.php
Expand Up @@ -2209,6 +2209,7 @@
],
],
],

'stats' => [
'$collection' => Database::METADATA,
'$id' => 'stats',
Expand Down Expand Up @@ -2294,6 +2295,7 @@
],
],
],

'realtime' => [
'$collection' => Database::METADATA,
'$id' => 'realtime',
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/account.php
Expand Up @@ -479,7 +479,7 @@
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;

if ($limit !== 0) {
$sum = $dbForProject->count('users', [ new Query('deleted', Query::TYPE_EQUAL, [false]),], APP_LIMIT_COUNT);
$sum = $dbForProject->count('users', [ new Query('deleted', Query::TYPE_EQUAL, [false]),], APP_LIMIT_USERS);

if ($sum >= $limit) {
throw new Exception('Project registration is restricted. Contact your administrator for more information.', 501);
Expand Down Expand Up @@ -652,7 +652,7 @@
if ($limit !== 0) {
$sum = $dbForProject->count('users', [
new Query('deleted', Query::TYPE_EQUAL, [false]),
], APP_LIMIT_COUNT);
], APP_LIMIT_USERS);

if ($sum >= $limit) {
throw new Exception('Project registration is restricted. Contact your administrator for more information.', 501);
Expand Down Expand Up @@ -924,7 +924,7 @@
if ($limit !== 0) {
$sum = $dbForProject->count('users', [
new Query('deleted', Query::TYPE_EQUAL, [false]),
], APP_LIMIT_COUNT);
], APP_LIMIT_USERS);

if ($sum >= $limit) {
throw new Exception('Project registration is restricted. Contact your administrator for more information.', 501);
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/projects.php
Expand Up @@ -461,7 +461,7 @@
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_PROJECT)
->param('projectId', '', new UID(), 'Project unique ID.')
->param('limit', false, new Integer(true), 'Set the max number of users allowed in this project. Use 0 for unlimited.')
->param('limit', false, new Range(0, APP_LIMIT_USERS), 'Set the max number of users allowed in this project. Use 0 for unlimited.')
->inject('response')
->inject('dbForConsole')
->action(function ($projectId, $limit, $response, $dbForConsole) {
Expand Down
4 changes: 2 additions & 2 deletions app/views/console/users/index.phtml
Expand Up @@ -353,13 +353,13 @@ $smtpEnabled = $this->getParam('smtpEnabled', false);
data-failure-param-alert-text="Failed to update project users limit"
data-failure-param-alert-classname="error">

<input name="limit" id="users-limit" type="number" data-ls-bind="{{console-project.authLimit}}" data-cast-to="numeric" min="0" />
<input name="limit" id="users-limit" type="number" data-ls-bind="{{console-project.authLimit}}" data-cast-to="numeric" min="0" max="<?php echo APP_LIMIT_USERS; ?>" />

<div class="info row thin margin-bottom margin-top">
<div class="col span-1">
<i class="icon-info-circled text-sign"></i>
</div>
<div class="col span-11">This limit will prevent new users from signing up for your project, no matter what auth method has been used. You will still be able to create users and team memberships from your Appwrite console. For an unlimited amount of users, set the limit to 0.</div>
<div class="col span-11">This limit will prevent new users from signing up for your project, no matter what auth method has been used. You will still be able to create users and team memberships from your Appwrite console. For an unlimited amount of users, set the limit to 0. Max limit is <?php echo number_format(APP_LIMIT_USERS); ?>.</div>
</div>

<button>Update</button> &nbsp; <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
Expand Down

0 comments on commit 464db81

Please sign in to comment.