作者:laherr
项目:user-managemen
/**
* @param bool $performValidation
*
* @return bool
*/
public function sendEmail($performValidation = true)
{
if ($performValidation and !$this->validate()) {
return false;
}
$this->user->generateConfirmationToken();
$this->user->save(false);
return Yii::$app->mailer->compose(Yii::$app->getModule('user-management')->mailerOptions['passwordRecoveryFormViewFile'], ['user' => $this->user])->setFrom(Yii::$app->getModule('user-management')->mailerOptions['from'])->setTo($this->email)->setSubject(UserManagementModule::t('front', 'Password reset for') . ' ' . Yii::$app->name)->send();
}
作者:gpis88c
项目:Gpis88c
/**
* Validates current password
*/
public function validateCurrentPassword()
{
if (!Yii::$app->getModule('user-management')->checkAttempts()) {
$this->addError('current_password', UserManagementModule::t('back', 'Too many attempts'));
return false;
}
if (!Yii::$app->security->validatePassword($this->current_password, $this->user->password_hash)) {
$this->addError('current_password', UserManagementModule::t('back', "Wrong password"));
}
}
作者:gpis88c
项目:Gpis88c
/**
* Check if user is binded to IP and compare it with his actual IP
*/
public function validateIP()
{
$user = $this->getUser();
if ($user and $user->bind_to_ip) {
$ips = explode(',', $user->bind_to_ip);
$ips = array_map('trim', $ips);
if (!in_array(LittleBigHelper::getRealIp(), $ips)) {
$this->addError('password', UserManagementModule::t('front', "You could not login from this IP"));
}
}
}
作者:alizowgh
项目:user-managemen
/**
* Add or remove child permissions (including routes) and return back to view
*
* @param string $id
*
* @return \yii\web\Response
*/
public function actionSetChildPermissions($id)
{
$role = $this->findModel($id);
$newChildPermissions = Yii::$app->request->post('child_permissions', []);
$oldChildPermissions = array_keys((new DbManager())->getPermissionsByRole($role->name));
$toRemove = array_diff($oldChildPermissions, $newChildPermissions);
$toAdd = array_diff($newChildPermissions, $oldChildPermissions);
Role::addChildren($role->name, $toAdd);
Role::removeChildren($role->name, $toRemove);
Yii::$app->session->setFlash('success', UserManagementModule::t('back', 'Saved'));
return $this->redirect(['view', 'id' => $id]);
}
作者:skoph
项目:user-managemen
/**
* Add or remove routes for this permission
*
* @param string $id
*
* @return \yii\web\Response
*/
public function actionSetChildRoutes($id)
{
$item = $this->findModel($id);
$newRoutes = Yii::$app->request->post('child_routes', []);
$oldRoutes = array_keys(AuthHelper::getChildrenByType($item->name, AbstractItem::TYPE_ROUTE));
$toAdd = array_diff($newRoutes, $oldRoutes);
$toRemove = array_diff($oldRoutes, $newRoutes);
Permission::addChildren($id, $toAdd);
Permission::removeChildren($id, $toRemove);
if (($toAdd or $toRemove) and $id == Yii::$app->getModule('user-management')->commonPermissionName) {
Yii::$app->cache->delete('__commonRoutes');
}
AuthHelper::invalidatePermissions();
Yii::$app->session->setFlash('success', UserManagementModule::t('back', 'Saved'));
return $this->redirect(['view', 'id' => $id]);
}
作者:gpis88c
项目:Gpis88c
/**
* @param int $id - User ID
*
* @return \yii\web\Response
*/
public function actionSetRoles($id)
{
if (!Yii::$app->user->isSuperadmin and Yii::$app->user->id == $id) {
Yii::$app->session->setFlash('error', UserManagementModule::t('back', 'You can not change own permissions'));
return $this->redirect(['set', 'id' => $id]);
}
$oldAssignments = array_keys(Role::getUserRoles($id));
// To be sure that user didn't attempt to assign himself some unavailable roles
$newAssignments = array_intersect(Role::getAvailableRoles(Yii::$app->user->isSuperAdmin, true), Yii::$app->request->post('roles', []));
$toAssign = array_diff($newAssignments, $oldAssignments);
$toRevoke = array_diff($oldAssignments, $newAssignments);
foreach ($toRevoke as $role) {
User::revokeRole($id, $role);
}
foreach ($toAssign as $role) {
User::assignRole($id, $role);
}
Yii::$app->session->setFlash('success', UserManagementModule::t('back', 'Saved'));
return $this->redirect(['set', 'id' => $id]);
}
作者:gpis88c
项目:Gpis88c
<?php
use webvimark\modules\UserManagement\UserManagementModule;
/**
* @var yii\web\View $this
* @var webvimark\modules\UserManagement\models\User $user
*/
$this->title = UserManagementModule::t('front', 'Registration - confirm your e-mail');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="registration-wait-for-confirmation">
<div class="alert alert-info text-center">
<?php
echo UserManagementModule::t('front', 'Check your e-mail {email} for instructions to activate account', ['email' => '<b>' . $user->email . '</b>']);
?>
</div>
</div>
作者:gpis88c
项目:Gpis88c
<?php
use webvimark\extensions\DateRangePicker\DateRangePicker;
use webvimark\modules\UserManagement\UserManagementModule;
use yii\helpers\Html;
use yii\widgets\Pjax;
use webvimark\extensions\GridPageSize\GridPageSize;
use yii\grid\GridView;
/**
* @var yii\web\View $this
* @var yii\data\ActiveDataProvider $dataProvider
* @var webvimark\modules\UserManagement\models\search\UserVisitLogSearch $searchModel
*/
$this->title = UserManagementModule::t('back', 'Visit log');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-visit-log-index">
<?php
// echo $this->render('_search', ['model' => $searchModel]);
?>
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class="col-sm-12 text-right">
<?php
echo GridPageSize::widget(['pjaxId' => 'user-visit-log-grid-pjax']);
?>
作者:gpis88c
项目:Gpis88c
/**
* @inheritdoc
*/
public function attributeLabels()
{
return ['id' => 'ID', 'token' => 'Token', 'ip' => 'IP', 'language' => UserManagementModule::t('back', 'Language'), 'browser' => UserManagementModule::t('back', 'Browser'), 'os' => UserManagementModule::t('back', 'OS'), 'user_agent' => UserManagementModule::t('back', 'User agent'), 'user_id' => UserManagementModule::t('back', 'User'), 'visit_time' => UserManagementModule::t('back', 'Visit Time')];
}
作者:laherr
项目:user-managemen
*/
$this->title = UserManagementModule::t('front', 'E-mail confirmed');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="change-own-password-success">
<div class="alert alert-success text-center">
<?php
echo UserManagementModule::t('front', 'E-mail confirmed');
?>
- <b><?php
echo $user->email;
?>
</b>
<?php
if (isset($_GET['returnUrl'])) {
?>
<br/>
<br/>
<b><?php
echo Html::a(UserManagementModule::t('front', 'Continue'), $_GET['returnUrl']);
?>
</b>
<?php
}
?>
</div>
</div>
作者:gpis88c
项目:Gpis88c
/**
* For Menu
*
* @return array
*/
public static function menuItems()
{
return [['label' => '<i class="fa fa-angle-double-right"></i> ' . UserManagementModule::t('back', 'Users'), 'url' => ['/user-management/user/index']], ['label' => '<i class="fa fa-angle-double-right"></i> ' . UserManagementModule::t('back', 'Roles'), 'url' => ['/user-management/role/index']], ['label' => '<i class="fa fa-angle-double-right"></i> ' . UserManagementModule::t('back', 'Permissions'), 'url' => ['/user-management/permission/index']], ['label' => '<i class="fa fa-angle-double-right"></i> ' . UserManagementModule::t('back', 'Permission groups'), 'url' => ['/user-management/auth-item-group/index']], ['label' => '<i class="fa fa-angle-double-right"></i> ' . UserManagementModule::t('back', 'Visit log'), 'url' => ['/user-management/user-visit-log/index']]];
}
作者:gpis88c
项目:Gpis88c
echo $this->title;
?>
</h2>
<div class="panel panel-default">
<div class="panel-body">
<p>
<?php
echo GhostHtml::a(UserManagementModule::t('back', 'Edit'), ['update', 'id' => $model->id], ['class' => 'btn btn-sm btn-primary']);
?>
<?php
echo GhostHtml::a(UserManagementModule::t('back', 'Create'), ['create'], ['class' => 'btn btn-sm btn-success']);
?>
<?php
echo GhostHtml::a(UserManagementModule::t('back', 'Roles and permissions'), ['/user-management/user-permission/set', 'id' => $model->id], ['class' => 'btn btn-sm btn-default']);
?>
<?php
echo GhostHtml::a(UserManagementModule::t('back', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-sm btn-danger pull-right', 'data' => ['confirm' => UserManagementModule::t('back', 'Are you sure you want to delete this user?'), 'method' => 'post']]);
?>
</p>
<?php
echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'status', 'value' => User::getStatusValue($model->status)], 'username', ['attribute' => 'email', 'value' => $model->email, 'format' => 'email', 'visible' => User::hasPermission('viewUserEmail')], ['attribute' => 'email_confirmed', 'value' => $model->email_confirmed, 'format' => 'boolean', 'visible' => User::hasPermission('viewUserEmail')], ['label' => UserManagementModule::t('back', 'Roles'), 'value' => implode('<br>', ArrayHelper::map(Role::getUserRoles($model->id), 'name', 'description')), 'visible' => User::hasPermission('viewUserRoles'), 'format' => 'raw'], ['attribute' => 'bind_to_ip', 'visible' => User::hasPermission('bindUserToIp')], array('attribute' => 'registration_ip', 'value' => Html::a($model->registration_ip, "http://ipinfo.io/" . $model->registration_ip, ["target" => "_blank"]), 'format' => 'raw', 'visible' => User::hasPermission('viewRegistrationIp')), 'created_at:datetime', 'updated_at:datetime']]);
?>
</div>
</div>
</div>
作者:gpis88c
项目:Gpis88c
<?php
use app\assets\AppAsset;
use webvimark\modules\UserManagement\UserManagementModule;
use yii\bootstrap\BootstrapAsset;
use yii\helpers\Html;
/* @var $this \yii\web\View */
/* @var $content string */
$this->title = UserManagementModule::t('front', 'Authorization');
BootstrapAsset::register($this);
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php
echo Yii::$app->language;
?>
">
<head>
<meta charset="<?php
echo Yii::$app->charset;
?>
"/>
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
echo Html::csrfMetaTags();
?>
<title><?php
echo Html::encode($this->title);
?>
</title>
作者:gpis88c
项目:Gpis88c
/**
* @return array
*/
public function attributeLabels()
{
return ['id' => 'ID', 'username' => UserManagementModule::t('back', 'Login'), 'superadmin' => UserManagementModule::t('back', 'Superadmin'), 'confirmation_token' => 'Confirmation Token', 'registration_ip' => UserManagementModule::t('back', 'Registration IP'), 'bind_to_ip' => UserManagementModule::t('back', 'Bind to IP'), 'status' => UserManagementModule::t('back', 'Status'), 'gridRoleSearch' => UserManagementModule::t('back', 'Roles'), 'created_at' => UserManagementModule::t('back', 'Created'), 'updated_at' => UserManagementModule::t('back', 'Updated'), 'password' => UserManagementModule::t('back', 'Password'), 'repeat_password' => UserManagementModule::t('back', 'Repeat password'), 'email_confirmed' => UserManagementModule::t('back', 'E-mail confirmed'), 'email' => 'E-mail'];
}
作者:gpis88c
项目:Gpis88c
?>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<?php
if ($model->isNewRecord) {
?>
<?php
echo Html::submitButton('<span class="glyphicon glyphicon-plus-sign"></span> ' . UserManagementModule::t('back', 'Create'), ['class' => 'btn btn-success']);
?>
<?php
} else {
?>
<?php
echo Html::submitButton('<span class="glyphicon glyphicon-ok"></span> ' . UserManagementModule::t('back', 'Save'), ['class' => 'btn btn-primary']);
?>
<?php
}
?>
</div>
</div>
<?php
ActiveForm::end();
?>
</div>
</div>
</div>
作者:gpis88c
项目:Gpis88c
<?php
use webvimark\modules\UserManagement\UserManagementModule;
/**
* @var yii\web\View $this
*/
$this->title = UserManagementModule::t('back', 'Change own password');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="change-own-password-success">
<div class="alert alert-success text-center">
<?php
echo UserManagementModule::t('back', 'Password has been changed');
?>
</div>
</div>
作者:gpis88c
项目:Gpis88c
<?php
echo $form->field($model, 'username')->textInput(['maxlength' => 50, 'autocomplete' => 'off', 'autofocus' => true]);
?>
<?php
echo $form->field($model, 'password')->passwordInput(['maxlength' => 255, 'autocomplete' => 'off']);
?>
<?php
echo $form->field($model, 'repeat_password')->passwordInput(['maxlength' => 255, 'autocomplete' => 'off']);
?>
<?php
echo $form->field($model, 'captcha')->widget(Captcha::className(), ['template' => '<div class="row"><div class="col-sm-2">{image}</div><div class="col-sm-3">{input}</div></div>', 'captchaAction' => ['/user-management/auth/captcha']]);
?>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<?php
echo Html::submitButton('<span class="glyphicon glyphicon-ok"></span> ' . UserManagementModule::t('front', 'Register'), ['class' => 'btn btn-primary']);
?>
</div>
</div>
<?php
ActiveForm::end();
?>
</div>
作者:gpis88c
项目:Gpis88c
<?php
use webvimark\modules\UserManagement\UserManagementModule;
/**
* @var yii\web\View $this
* @var webvimark\modules\UserManagement\models\User $user
*/
$this->title = UserManagementModule::t('front', 'E-mail confirmed');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="change-own-password-success">
<div class="alert alert-success text-center">
<?php
echo UserManagementModule::t('front', 'E-mail confirmed');
?>
- <b><?php
echo $user->email;
?>
</b>
</div>
</div>
作者:alizowgh
项目:user-managemen
/**
* @inheritdoc
*/
public function attributeLabels()
{
return ['name' => UserManagementModule::t('back', 'Name'), 'code' => UserManagementModule::t('back', 'Code'), 'created_at' => UserManagementModule::t('back', 'Created'), 'updated_at' => UserManagementModule::t('back', 'Updated')];
}
作者:gpis88c
项目:Gpis88c
echo $form->field($model, 'rememberMe')->checkbox(['value' => true]);
?>
<?php
echo Html::submitButton(UserManagementModule::t('front', 'Login'), ['class' => 'btn btn-lg btn-primary btn-block']);
?>
<div class="row registration-block">
<div class="col-sm-6">
<?php
echo GhostHtml::a(UserManagementModule::t('front', "Registration"), ['/user-management/auth/registration']);
?>
</div>
<div class="col-sm-6 text-right">
<?php
echo GhostHtml::a(UserManagementModule::t('front', "Forgot password ?"), ['/user-management/auth/password-recovery']);
?>
</div>
</div>
<?php
ActiveForm::end();
?>
</div>
</div>
</div>
</div>
</div>