//NEW if (isset($_POST['a_username']) && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) { if (CODOF\Util::is_field_present($_POST['a_username'], 'username') === TRUE) { } else { if (CODOF\Util::is_field_present($_POST['a_email'], 'mail') === TRUE) { } else { if (CODOF\User\User::usernameExists($_POST['a_username']) || CODOF\User\User::mailExists($_POST['a_email'])) { $msg = 'username or email already exists!'; } else { $reg = new CODOF\User\Register($db); $reg->username = $_POST['a_username']; $reg->name = $_POST['a_username']; $reg->mail = $_POST['a_email']; $reg->password = $_POST['a_password']; $reg->user_status = 1; $errors = $reg->register_user(); $msg = implode('<br>', $errors); } //$msg = $errors[0]; $err = 1; $smarty->assign("msg", $msg); } } } //DELETE if (isset($_POST['delete_type']) && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) { $msg = ""; $user = CODOF\User\User::get((int) $_POST['delete_id']); if ($user == false) { $_POST['delete_type'] = 'error'; $msg .= "User does not exist.<br>";
$create_account = false; CODOF\User\User::login($res['id']); //now this will work if you change authentication from //fb to gmail etc } } if ($create_account) { $reg = new CODOF\User\Register($db); $reg->mail = $mail; $reg->name = $user_profile->firstName . ' ' . $user_profile->lastName; $reg->oauth_id = $oauth_id; $reg->username = $username; $reg->avatar = $user_profile->photoURL; $reg->user_status = 1; //approved user $reg->register_user(); $reg->login(); } } header('Location: ' . CODOF\User\User::getProfileUrl()); //$adapter->logout(); } catch (Exception $e) { // In case we have errors 6 or 7, then we have to use Hybrid_Provider_Adapter::logout() to // let hybridauth forget all about the user so we can try to authenticate again. // Display the recived error, // to know more please refer to Exceptions handling section on the userguide switch ($e->getCode()) { case 0: echo "Unspecified error."; break; case 1:
public function register($do) { if (isset($_SESSION[UID . 'USER']['id'])) { header('Location: ' . \CODOF\User\User::getProfileUrl()); exit; } $this->view = 'user/register'; $set_fields = array('username', 'password', 'mail'); $req_fields = array('username', 'password', 'mail'); $this->js_files = array(array(DATA_PATH . 'assets/js/user/register.js', array('type' => 'defer'))); if (\CODOF\Util::is_set($_REQUEST, $set_fields) && !\CODOF\Util::is_empty($_REQUEST, $req_fields) && $do) { $register = new \CODOF\User\Register($this->db); $register->username = str_replace('"', '"', $_REQUEST['username']); $register->name = null; //$_REQUEST['name']; $register->password = $_REQUEST["password"]; $register->mail = $_REQUEST['mail']; $register->rid = ROLE_UNVERIFIED; $errors = $register->get_errors(); if (empty($errors)) { $errors = $register->register_user(); $register->login(); header('Location: ' . \CODOF\User\User::getProfileUrl()); exit; } $this->smarty->assign('errors', $errors); } else { $register = new \stdClass(); $register->username = null; $register->name = null; //$_REQUEST['name']; $register->password = null; $register->mail = null; } if (\CODOF\Util::get_opt('captcha') == "enabled") { $publickey = \CODOF\Util::get_opt('captcha_public_key'); // you got this from the signup page $this->smarty->assign('recaptcha', '<div class="g-recaptcha col-md-6" data-sitekey="' . $publickey . '"></div>'); $this->js_files[] = array('https://www.google.com/recaptcha/api.js', array('type' => 'remote')); } $this->smarty->assign('min_pass_len', \CODOF\Util::get_opt('register_pass_min')); $this->smarty->assign('min_username_len', \CODOF\Util::get_opt('register_username_min')); $this->smarty->assign('register', $register); \CODOF\Store::set('sub_title', 'Register'); }