コード例 #1
0
 public function Controller_Signin($Sender)
 {
     $subdomain = C(self::CONFIG_PREFIX . 'ApiSubdomain', '');
     $api_credentials = array();
     $api_credentials['api_key'] = C(self::CONFIG_PREFIX . 'ApiKey', '');
     $api_credentials['api_secret'] = C(self::CONFIG_PREFIX . 'ApiSecret', '');
     if (empty($subdomain) || empty($api_credentials['api_key']) || empty($api_credentials['api_secret'])) {
         // TODO figure out best action to take here:
         return;
     }
     $oa_action = Gdn::Request()->Post('oa_action');
     $oa_login_token = Gdn::Request()->Post('oa_social_login_token');
     $oa_connection_token = Gdn::Request()->Post('connection_token');
     if (C(self::CONFIG_PREFIX . 'Enable', 1) != '1' || empty($oa_action) || empty($oa_connection_token)) {
         // TODO figure out best action to take here: should not happen, as checked when rendering pages.
         return;
     }
     $use_curl = C(self::CONFIG_PREFIX . 'Curl', 1);
     $use_ssl = C(self::CONFIG_PREFIX . 'SSL', 1);
     $linking = C(self::CONFIG_PREFIX . 'LinkingEnable', 1);
     $validation = C(self::CONFIG_PREFIX . 'Validate', 0);
     $avatar = C(self::CONFIG_PREFIX . 'AvatarsEnable', 1);
     $redirect = C(self::CONFIG_PREFIX . 'Redirect', '');
     $oasl = new SocialLogin();
     $to_validate = $oasl->handle_callback($oa_action, $oa_login_token, $oa_connection_token, $use_curl, $use_ssl, $subdomain, $api_credentials, $linking, $validation, $avatar, $redirect);
     if (is_array($to_validate)) {
         $Sender->Form = new Gdn_Form();
         // TODO maybe not needed.
         $to_validate['val_id'] = $oasl->set_validation_data($to_validate);
         $Sender = $this->set_validation_fields($Sender, $to_validate);
         $Sender->Render($this->GetView('oa_social_login_validate.php'));
     }
 }