public function verifyContact() { $bud = Bud::FindByEmail(@$_POST['email']); if (@$_POST['verify_email']) { if ($_POST['verify_email'] != $bud->email_code) { $this->api_die('Wrong email verification code, try again'); } $bud->is_email_verified = 1; } if (@$_POST['verify_phone']) { if ($_POST['verify_phone'] != $bud->phone_code) { $this->api_die('Wrong phone verification code, try again'); } $bud->is_phone_verified = 1; } $bud->save(); $this->api_success(); }
protected function validateNotExisting($email_or_phone, $val) { try { $bud = Bud::FindBy($email_or_phone, $val); // has this user already been verified? if ($bud->is_email_verified == 1 || $bud->is_phone_verified == 1) { $this->api_die("That {$email_or_phone} is already registered"); } // if it hasn't been verified yet, just delete the bud to recreate him later $bud->delete(); } catch (ModelNotFoundException $e) { } }