Пример #1
0
                 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:
             echo "Hybridauth configuration error.";
Пример #2
0
 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');
 }