From c44ee1cb1b2b81ddc6ee0cd812cffea55c92bc19 Mon Sep 17 00:00:00 2001 From: Pierre Date: Mon, 21 May 2018 10:27:07 +0200 Subject: [PATCH] Added a method to check if an email is associated or not with an account. --- RestControllers/accountController.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/RestControllers/accountController.php b/RestControllers/accountController.php index 706a9fa..127eea1 100644 --- a/RestControllers/accountController.php +++ b/RestControllers/accountController.php @@ -62,6 +62,26 @@ class accountController { return array("success" => "The user has been disconnected !"); } + /** + * Check if an email is already associated with an account or not + * + * @url POST /account/exists_email + */ + public function existsMail(){ + + //Check the given email address + $email = postString("email", 5); + if(!filter_var($email, FILTER_VALIDATE_EMAIL)) + Rest_fatal_error(400, "Specified email address is invalid !"); + + //Check if the email address is already associated with an account + $email_exists = components()->account->exists_email($email); + + return array( + "exists" => $email_exists + ); + } + /** * Create an account *