auth.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: NODELOG
  5. * DateTime: 2017/3/20 13:55
  6. * Description:
  7. */
  8. use yii\helpers\Html;
  9. use common\modules\user\widgets\AuthChoice;
  10. $this->title = '授权管理';
  11. ?>
  12. <div class="row">
  13. <div class="col-md-3">
  14. <?= $this->render('../_menu') ?>
  15. </div>
  16. <div class="col-md-9">
  17. <div class="panel panel-default">
  18. <div class="panel-heading">
  19. <?= Html::encode($this->title) ?>
  20. </div>
  21. <div class="panel-body">
  22. <div class="alert alert-info">
  23. <p><?= Yii::t('app', 'You can connect multiple accounts to be able to log in using them') ?>.</p>
  24. </div>
  25. <?php $auth = AuthChoice::begin([
  26. 'baseAuthUrl' => ['/user/security/auth'],
  27. 'autoRender' => false,
  28. 'popupMode' => false,
  29. ]) ?>
  30. <table class="table">
  31. <?php foreach ($auth->getClients() as $client): ?>
  32. <tr>
  33. <td style="width: 32px; vertical-align: middle">
  34. <?= Html::tag('span', '', ['class' => 'auth-icon ' . $client->getName()]) ?>
  35. </td>
  36. <td style="vertical-align: middle">
  37. <strong><?= $client->getTitle() ?></strong>
  38. </td>
  39. <td style="width: 120px">
  40. <?= $auth->isConnected($client) ?
  41. Html::a(Yii::t('app', 'Disconnect'), ['disconnect', 'id' => $client->getId()], [
  42. 'class' => 'btn btn-danger btn-block',
  43. 'data-method' => 'post',
  44. ]) :
  45. Html::a(Yii::t('app', 'Connect'), $auth->createClientUrl($client), [
  46. 'class' => 'btn btn-success btn-block',
  47. ])
  48. ?>
  49. </td>
  50. </tr>
  51. <?php endforeach; ?>
  52. </table>
  53. <?php AuthChoice::end() ?>
  54. </div>
  55. </div>
  56. </div>
  57. </div>