It opens a popup window for the client authentication process. By default this widget relies on presence of Collection among application components to get auth clients information. Example: php ['site/auth'] ]); ?> You can customize the widget appearance by using [[begin()]] and [[end()]] syntax along with using method AuthChoice::clientLink or AuthChoice::createClientUrl. For example: php ['site/auth'] ]); ?>
    getClients() as $client): ?>
  • clientLink($client) ?>
This widget supports following keys for [[ClientInterface::getViewOptions()]] result: - popupWidth: int, width of the popup window in pixels. - popupHeight: int, height of the popup window in pixels. - widget: array, configuration for the widget, which should be used to render a client link; such widget should be a subclass of [[AuthChoiceItem]].
See also: yii\authclient\AuthAction
Since: 2.0
Author: Paul Klimov (klimov.paul@gmail.com)
Inheritance: extends yii\base\Widget
Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function createClientUrl($provider)
 {
     if ($this->isConnected($provider)) {
         return Url::to(['/user/setting/disconnect', 'id' => $this->accounts[$provider->getId()]->id]);
     } else {
         return parent::createClientUrl($provider);
     }
 }
Exemplo n.º 2
0
$AuthAuthChoiceClients = $authAuthChoice->getClients();
if (!empty($AuthAuthChoiceClients)) {
    ?>
            <div class="social-auth-links text-center">
                <p>- OR -</p>
                <?php 
    foreach ($authAuthChoice->getClients() as $Client) {
        $name = $Client->getName();
        $icon = $name;
        if ($icon === 'live') {
            $icon = 'windows';
        }
        if ($icon === 'vkontakte') {
            $icon = 'vk';
        }
        if ($icon === 'yandex') {
            $icon = 'yahoo';
        }
        $icon = FA::icon($icon);
        echo Html::a(sprintf('%s Sign in using %s', $icon, $Client->getName()), $authAuthChoice->createClientUrl($Client), ['class' => sprintf('btn btn-block btn-flat btn-social btn-%s', $name)]);
    }
    ?>
            </div>
            <?php 
}
\yii\authclient\widgets\AuthChoice::end();
?>

        <a href="#">I forgot my password</a><br>
    </div>
</div>
Exemplo n.º 3
0
        $class = $name === 'live' ? 'windows' : $name;
        ?>
                        <?php 
        $text = sprintf('<i class="%s">%s</i>&nbsp;%s', "fa fa-{$class}", $letter, $client->getTitle());
        ?>
                        <?php 
        echo $authAuthChoice->clientLink($client, $text, ['class' => "btn btn-block btn-social btn-{$class}"]);
        ?>
                    </div>
                <?php 
    }
    ?>
                </div>
            </div>
        <?php 
    AuthChoice::end();
    ?>
    <?php 
}
?>

    <?php 
foreach (['restore-password', 'signup', 'login'] as $action) {
    ?>
        <?php 
    if ($widget->isShown($action)) {
        ?>
            <br/>
            <?php 
        echo Html::a($widget->getText($action), $widget->getPage($action));
        ?>
Exemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $this->view->registerCss('.y2u-social-connects .auth-clients{margin:0;padding:0}');
     parent::init();
 }
Exemplo n.º 5
0
<?php

/* @var $this yii\web\View */
use yii\authclient\widgets\AuthChoice;
use yii\bootstrap\Modal;
?>

<?php 
if (Yii::$app->user->isGuest) {
    Yii::$app->user->setReturnUrl(Yii::$app->request->getUrl());
    ?>
    <h4>
        <?php 
    echo Modal::widget(['header' => 'Логин', 'toggleButton' => ['class' => 'btn-link', 'label' => 'Войти', 'onclick' => '$(this).next().find(".modal-body").load("/user/user/login");']]);
    ?>
        |
        <?php 
    echo Modal::widget(['header' => 'Регистрация', 'toggleButton' => ['class' => 'btn-link', 'label' => 'Зарегистрироваться', 'onclick' => '$(this).next().find(".modal-body").load("/user/user/signup");']]);
    ?>
    </h4>
    <?php 
    echo yii\authclient\widgets\AuthChoice::widget(['baseAuthUrl' => ['/user/auth/auth']]);
}
Exemplo n.º 6
0
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="user-form">
    <h1><?php 
echo Yii::t('app', 'Signup');
?>
</h1>

    <?php 
$form = ActiveForm::begin();
?>

    <br/>
    <?php 
echo AuthChoice::widget(['baseAuthUrl' => ['social']]);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
    <?php 
echo $form->field($model, 'email')->textInput(['maxlength' => true]);
?>
    <?php 
echo $form->field($model, 'password')->passwordInput();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton(Yii::t('app', 'Signup'), ['class' => 'btn btn-success']);
Exemplo n.º 7
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->setBaseAuthUrl([Module::URL_ROUTE_CLIENT_AUTH]);
 }
Exemplo n.º 8
0
/* @var $this View */
$model = Yii::$app->user->identity;
$this->title = "{$model->displayName} #{$model->id}";
$this->params['breadcrumbs'][] = ['label' => Yii::t(Module::I18N_CATEGORY, 'Profile'), 'url' => ['view']];
$this->params['breadcrumbs'][] = $this->title;
?>

<?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['username', 'email:email', 'statusName', 'created_at:datetime', 'updated_at:datetime', 'confirmed_on:datetime']]);
?>

<?php 
if ($model->userAccounts) {
    ?>
    <h2>Linked accounts</h2>
    <?php 
    echo GridView::widget(['dataProvider' => new ArrayDataProvider(['allModels' => $model->userAccounts]), 'columns' => ['provider', 'client_id', 'token_create_time:datetime', 'expires:datetime', ['value' => function ($model) {
        $data = json_decode($model->attributes);
        $text = VarDumper::dumpAsString((array) $data, 10, true);
        return $text;
    }, 'format' => 'raw']]]);
}
?>
    
<?php 
if (Yii::$app->get('authClientCollection', false)) {
    ?>
<h2>Account linking</h2>
    <?php 
    echo DetailView::widget(['model' => $model, 'attributes' => [['label' => 'Link accounts', 'format' => 'raw', 'value' => AuthChoice::widget(['baseAuthUrl' => ['/' . $this->context->module->id . '/security/auth'], 'popupMode' => false])]]]);
}
Exemplo n.º 9
0
				<div class="col-sm-offset-3 col-sm-9">
                <?php 
echo Html::submitButton('登录', ['class' => 'btn btn-primary', 'name' => 'login-button']);
?>
				&nbsp;&nbsp;<?php 
echo Html::a('忘记密码了', ['site/forgot-password']);
?>
				</div>
            </div>
            <?php 
ActiveForm::end();
if (intval(Yii::$app->params['settings']['auth_enabled']) === 1) {
    ?>
			<h6 class="login-three-home"><strong>第三方账号直接登录</strong></h6>
			<?php 
    echo \yii\authclient\widgets\AuthChoice::widget(['baseAuthUrl' => ['site/auth'], 'popupMode' => false]);
}
?>
		</div>
	</div>

</div>
<!-- sf-left end -->

<!-- sf-right start -->
<div class="col-md-4 sf-right">
<?php 
echo $this->render('@app/views/common/_right');
?>
</div>
<!-- sf-right end -->
Exemplo n.º 10
0
 /**
  * @inheritdoc
  */
 public function clientLink($client, $text = null, array $htmlOptions = array())
 {
     $viewOptions = $client->getViewOptions();
     if (isset($viewOptions['widget'])) {
         parent::clientLink($client, $text, $htmlOptions);
         return;
     }
     if (isset($viewOptions['buttonBackgroundColor'])) {
         $textColor = isset($viewOptions['buttonColor']) ? $viewOptions['buttonColor'] : '#FFF';
         $btnStyle = Html::cssStyleFromArray(['color' => $textColor . '!important', 'background-color' => $viewOptions['buttonBackgroundColor'] . '!important']);
         $btnClasses = '.btn-ac-' . $client->getName() . ', .btn-ac-' . $client->getName() . ':hover, .btn-ac-' . $client->getName() . ':active, .btn-ac-' . $client->getName() . ':visited';
         if ($this->showButtonColors) {
             echo Html::style($btnClasses . ' {' . $btnStyle . '}');
         }
     }
     if (!isset($htmlOptions['class'])) {
         $htmlOption['class'] = '';
     }
     $htmlOptions['class'] .= ' ' . 'btn btn-default btn-ac-' . $client->getName();
     $icon = isset($viewOptions['cssIcon']) ? '<i class="' . $viewOptions['cssIcon'] . '" aria-hidden="true"></i>' : '';
     echo parent::clientLink($client, $icon . $client->getTitle(), $htmlOptions);
     return;
     parent::clientLink($client, $text, $htmlOptions);
 }
Exemplo n.º 11
0
ActiveForm::end();
?>
            </div>
        </div>

        <?php 
if ($module->allowRegistration) {
    ?>
            <p class="text-center">
                <?php 
    echo Html::a(Yii::t(Module::I18N_CATEGORY, 'Don\'t have an account yet? Sign up!'), ['/user/registration/signup']);
    ?>
            </p>
        <?php 
}
?>

        <?php 
if (Yii::$app->get('authClientCollection', false)) {
    ?>
            <div>
                <?php 
    echo AuthChoice::widget(['baseAuthUrl' => ['/' . $this->context->module->id . '/security/auth'], 'popupMode' => false]);
    ?>
            </div>
        <?php 
}
?>

    </div>
</div>
Exemplo n.º 12
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     $view = Yii::$app->getView();
     AuthAsset::register($view);
     parent::init();
 }
Exemplo n.º 13
0
<?php

use Yii;
use yii\helpers\Html;
use yii\authclient\widgets\AuthChoice;
?>

<?php 
if (!Yii::$app->user->isGuest) {
    echo Yii::$app->user->identity->email . ' :: ' . Html::a('Logout', ['/account/auth/logout']);
} else {
    echo AuthChoice::widget(['baseAuthUrl' => ['auth/oauthtest']]);
}
Exemplo n.º 14
0
<?php

use yii\authclient\widgets\AuthChoice;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model app\models\User */
$this->title = Yii::$app->user->isGuest ? Yii::t('app', 'Signup') : Yii::t('app', 'Create User');
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Users'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-create">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
if (Yii::$app->user->isGuest) {
    echo '<br/>' . AuthChoice::widget(['baseAuthUrl' => ['social']]);
}
?>
    <?php 
echo $this->render('_form', ['model' => $model]);
?>

</div>
Exemplo n.º 15
0
<?php 
}
if ($this->context->module->registrationEnabled) {
    ?>
            <p style="color:#999;margin:1em 0">
                <?php 
    echo Yii::t('usr', 'Don\'t have an account yet?');
    ?>
                <?php 
    echo Yii::t('usr', 'Go to {link}.', ['link' => Html::a(Yii::t('usr', 'registration'), ['register'])]);
    ?>
            </p>
<?php 
}
if (Yii::$app->has('authClientCollection')) {
    echo \yii\authclient\widgets\AuthChoice::widget(['baseAuthUrl' => ['/usr/auth/popup']]);
}
?>
            <div class="form-group">
                <?php 
echo Html::submitButton(Yii::t('usr', 'Log in'), ['class' => 'btn btn-primary']);
?>
            </div>
        </div>
    </div>

<?php 
ActiveForm::end();
?>
</div><!-- form -->
Exemplo n.º 16
0
<?php

/* @var $this yii\web\View */
use yii\helpers\Html;
$this->title = 'Login';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-login">
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo \yii\authclient\widgets\AuthChoice::widget(['baseAuthUrl' => ['site/auth']]);
?>

</div>
Exemplo n.º 17
0
							<?php 
    echo Html::a(Yii::t('user', 'Forgot your password?'), Yii::$app->urlManager->createUrl('//user/recovery/recover-password'));
    ?>
						</small>
					</div>
				<?php 
}
?>
			</div>

			<?php 
if ($canRegister == 1) {
    ?>
				<hr>
				<?php 
    echo Html::a(Yii::t('user', 'Don\'t have an account?'), Yii::$app->urlManager->createUrl('//user/registration/register'));
    ?>
			<?php 
}
?>

			<?php 
echo AuthChoice::widget(['baseAuthUrl' => ['/user/auth/authenticate']]);
?>

			<?php 
$form::end();
?>
		</div>
	</div>
</div>