Ejemplo n.º 1
0
Archivo: Plugin.php Proyecto: jiiis/ptn
 public function boot()
 {
     User::extend(function ($model) {
         $model->hasMany['flynsarmy_sociallogin_providers'] = ['Flynsarmy\\SocialLogin\\Models\\Provider'];
     });
     Event::listen('backend.form.extendFields', function (Form $form) {
         if (!$form->getController() instanceof \System\Controllers\Settings) {
             return;
         }
         if (!$form->model instanceof \Flynsarmy\SocialLogin\Models\Settings) {
             return;
         }
         foreach (ProviderManager::instance()->listProviders() as $class => $details) {
             $classObj = $class::instance();
             $classObj->extendSettingsForm($form);
         }
     });
     Event::listen('backend.form.extendFields', function ($widget) {
         if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
             return;
         }
         if ($widget->getContext() != 'update') {
             return;
         }
         $widget->addFields(['flynsarmy_sociallogin_providers' => ['label' => 'Social Providers', 'type' => 'Flynsarmy\\SocialLogin\\FormWidgets\\LoginProviders']], 'secondary');
     });
 }
Ejemplo n.º 2
0
 /**
  * Executed when this component is bound to a page or layout.
  */
 public function onRun()
 {
     $providers = ProviderManager::instance()->listProviders();
     // MarkupManager::instance()->registerFunctions([
     // 	function($provider, $success_redirect='/', $error_redirect='/login') {
     // 		$settings = Settings::instance()->getHauthProviderConfig();
     // 		$is_enabled = !empty($settings[$provider]);
     // 		if ( !$is_enabled )
     // 			return '#';
     // 		return ProviderManager::instance()->getBaseURL($provider) .
     // 			'?s=' . URL::to($success_redirect) .
     // 			'&f=' . URL::to($error_redirect);
     // 	}
     // ]);
     $social_login_links = [];
     foreach ($providers as $provider_class => $provider_details) {
         if ($provider_class::instance()->isEnabled()) {
             $social_login_links[$provider_details['alias']] = URL::route('flynsarmy_sociallogin_provider', [$provider_details['alias']]);
         }
     }
     $this->page['social_login_links'] = $social_login_links;
     $this->page['errors'] = Session::get('errors', new ViewErrorBag());
 }