From 259b8be3b50e402d848119a788cdba84b9a329a3 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 11 Apr 2018 11:19:37 +0200 Subject: [PATCH] Can check if a mail is linked to an account or not. --- classes/components/account.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/classes/components/account.php b/classes/components/account.php index 6e8c567..7117d40 100644 --- a/classes/components/account.php +++ b/classes/components/account.php @@ -157,6 +157,23 @@ class Account { return $userInfos[0]["ID_utilisateurs"]; } + /** + * Check whether an email address is linked to an account or not + * + * @return bool TRUE if the email is linked to an account / FALSE else + */ + public function exists_email(string $email) : bool { + + //Perform an API request + $tableName = self::USER_TABLE; + $conditions = "WHERE mail = ?"; + $values = array($email); + + //Return result + return CS::get()->db->count($tableName, $conditions, $values) > 0; + + } + /** * Crypt user password *