当前位置: 首页>>代码示例>>PHP>>正文


PHP Social::include_vendor方法代码示例

本文整理汇总了PHP中Social::include_vendor方法的典型用法代码示例。如果您正苦于以下问题:PHP Social::include_vendor方法的具体用法?PHP Social::include_vendor怎么用?PHP Social::include_vendor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Social的用法示例。


在下文中一共展示了Social::include_vendor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_login

 public function action_login()
 {
     //if user loged in redirect home
     if (Auth::instance()->logged_in()) {
         Auth::instance()->login_redirect();
     }
     Social::include_vendor();
     $user = FALSE;
     $config = Social::get();
     if ($this->request->query('hauth_start') or $this->request->query('hauth_done')) {
         try {
             Hybrid_Endpoint::process($this->request->query());
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, $e->getMessage());
             $this->redirect(Route::url('default'));
         }
     } else {
         $provider_name = $this->request->param('id');
         try {
             // initialize Hybrid_Auth with a given file
             $hybridauth = new Hybrid_Auth($config);
             // try to authenticate with the selected provider
             if ($provider_name == 'openid') {
                 $params = array('openid_identifier' => 'https://openid.stackexchange.com/');
             } else {
                 $params = NULL;
             }
             $adapter = $hybridauth->authenticate($provider_name, $params);
             if ($hybridauth->isConnectedWith($provider_name)) {
                 //var_dump($adapter->getUserProfile());
                 $user_profile = $adapter->getUserProfile();
             }
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, __('Error: please try again!') . " " . $e->getMessage());
             $this->redirect(Route::url('default'));
         }
         //try to login the user with same provider and identifier
         $user = Auth::instance()->social_login($provider_name, $user_profile->identifier);
         //we couldnt login create account
         if ($user == FALSE) {
             $email = $user_profile->emailVerified != NULL ? $user_profile->emailVerified : $user_profile->email;
             $name = $user_profile->firstName != NULL ? $user_profile->firstName . ' ' . $user_profile->lastName : $user_profile->displayName;
             //if not email provided
             if (!Valid::email($email, TRUE)) {
                 Alert::set(Alert::INFO, __('We need your email address to complete'));
                 //redirect him to select the email to register
                 $this->redirect(Route::url('default', array('controller' => 'social', 'action' => 'register', 'id' => $provider_name)) . '?uid=' . $user_profile->identifier . '&name=' . $name);
             } else {
                 //register the user in DB
                 Model_User::create_social($email, $name, $provider_name, $user_profile->identifier);
                 //log him in
                 Auth::instance()->social_login($provider_name, $user_profile->identifier);
             }
         } else {
             Alert::set(Alert::SUCCESS, __('Welcome!'));
         }
         $this->redirect(Session::instance()->get_once('auth_redirect', Route::url('default')));
     }
 }
开发者ID:JeffPedro,项目名称:project-garage-sale,代码行数:59,代码来源:social.php


注:本文中的Social::include_vendor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。