Limit the number of account / hour / ip

This commit is contained in:
Pierre HUBERT 2018-08-20 14:48:21 +02:00
parent 5bddd624ca
commit 4937e66c71
2 changed files with 11 additions and 1 deletions

View File

@ -225,6 +225,8 @@ class accountController {
*/ */
public function createAccount(){ public function createAccount(){
api_limit_query(APILimits::ACTION_CREATE_ACCOUNT, false);
//Check post fields existence //Check post fields existence
if(!check_post_parametres(array("emailAddress", "firstName", "lastName", "password"))) if(!check_post_parametres(array("emailAddress", "firstName", "lastName", "password")))
Rest_fatal_error(400, "Please check given parameters"); Rest_fatal_error(400, "Please check given parameters");
@ -261,6 +263,8 @@ class accountController {
if(!components()->account->create($newAccount)) if(!components()->account->create($newAccount))
Rest_fatal_error(500, "An error occured while trying to create the account !"); Rest_fatal_error(500, "An error occured while trying to create the account !");
api_limit_query(APILimits::ACTION_CREATE_ACCOUNT, true);
//Success //Success
return array( return array(
"success" => "The account has been created !" "success" => "The account has been created !"

View File

@ -21,6 +21,7 @@ class APILimits {
* Actions list * Actions list
*/ */
const ACTION_LOGIN_FAILED = "failed_login"; const ACTION_LOGIN_FAILED = "failed_login";
const ACTION_CREATE_ACCOUNT = "create_account";
/** /**
* Actions configruation * Actions configruation
@ -30,7 +31,12 @@ class APILimits {
//Login failed //Login failed
self::ACTION_LOGIN_FAILED => array( self::ACTION_LOGIN_FAILED => array(
"limit" => 10 "limit" => 10
) ),
//Create an account
self::ACTION_CREATE_ACCOUNT => array(
"limit" => 10
),
); );
/** /**