Answer the question
In order to leave comments, you need to log in
Yii pass-through authorization by username?
using getenv("username")
I can find out the current user. how to implement a button on the login tab to find out if there is such a user in the database? something like
else if (getenv("username") == $user->id )
{
$this->_id = $user->id;
$this->username = $user->login;
$this->errorCode = self::ERROR_NONE;
}
<h1>Вход</h1>
<p></p>
<div class="form">
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'login-form',
'enableClientValidation' => true,
'clientOptions' => array(
'validateOnSubmit' => true,
),
));
?>
<p class="note">Поля с <span class="required">*</span> обязательны.</p>
<div class="row">
<?php echo CHtml::label('Имя', 'n'); ?>
<?php echo $form->textField($model, 'username'); ?>
<?php echo $form->error($model, 'username'); ?>
</div>
<div class="row">
<?php echo CHtml::label('Пароль', 'p'); ?>
<?php echo $form->passwordField($model, 'password'); ?>
<?php echo $form->error($model, 'password'); ?>
<p class="hint">
Для получения данных для входа обратитесь к администратору
</p>
</div>
<div class="row rememberMe">
<?php echo $form->checkBox($model, 'rememberMe'); ?>
<?php echo CHtml::label('Запомнить', 'r'); ?>
<?php echo $form->error($model, 'rememberMe'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Вход'); ?>
</div>
<?php $this->endWidget(); ?>
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'ldap_login',
'enableClientValidation' => true,
'clientOptions' => array(
'validateOnSubmit' => true,
),
));
?>
<?php echo CHtml::submitButton('Вход под текущим пользователем'); ?>
<?php $this->endWidget(); ?>
</div><!-- form -->
$ldapuser = User::model()->find('LOWER(login)=?', array(strtolower(getenv("username"))));
else if ($ldapuser)
{
$this->_id = $ldapuser->id;
$this->username = $ldapuser->login;
$this->errorCode = self::ERROR_NONE;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question