Ejemplo n.º 1
0
 public static function requireMinimumRole($role_name)
 {
     if (Yii::$app->user->identity->role_id >= ValueHelpers::getRoleValue($role_name)) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 public function loginAdmin()
 {
     if ($this->validate() && $this->getUser()->role_id >= ValueHelpers::getRoleValue('Admin') && $this->getUser()->status_id == ValueHelpers::getStatusValue('Active')) {
         return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
     } else {
         throw new NotFoundHttpException('You Shall Not Pass.');
     }
 }
Ejemplo n.º 3
0
 public function loginAdmin()
 {
     if ($this->validate() && $this->getUser()->role_id >= ValueHelpers::getRoleNameValue('Admin') && $this->getUser()->status_id == ValueHelpers::getStatusNameValue('Active')) {
         return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
     } else {
         return false;
     }
 }
Ejemplo n.º 4
0
 public static function requireMinimumRole($role_name, $userId = null)
 {
     if (ValueHelpers::isRoleNameValid($role_name)) {
         if ($userId == null) {
             $userRoleValue = ValueHelpers::getUsersRoleValue();
         } else {
             $userRoleValue = ValueHelpers::getUsersRoleValue($userId);
         }
         return $userRoleValue >= ValueHelpers::getRoleValue($role_name) ? true : false;
     } else {
         return false;
     }
 }
 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = User::findOne(['status_id' => ValueHelpers::getStatusId('Active'), 'email' => $this->email]);
     if ($user) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send();
         }
     }
     return false;
 }
Ejemplo n.º 6
0
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
?>

<div class="wrap">
    <?php 
$is_admin = ValueHelpers::getRoleValue("Admin");
if (!Yii::$app->user->isGuest) {
    NavBar::begin(['brandLabel' => 'Yii 2 build <i class="fa fa-plug"></i> Admin', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
} else {
    NavBar::begin(['brandLabel' => 'Yii 2 Build <i class="fa fa-plug"></i>', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
}
$menuItems = [['label' => 'Home', 'url' => ['/site/index']]];
if (!Yii::$app->user->isGuest && Yii::$app->user->identity->role_id >= $is_admin) {
    $menuItems[] = ['label' => 'Users', 'url' => ['user/index']];
    $menuItems[] = ['label' => 'Profiles', 'url' => ['profile/index']];
    $menuItems[] = ['label' => 'Roles', 'url' => ['/role/index']];
    $menuItems[] = ['label' => 'User Types', 'url' => ['/user-type/index']];
    $menuItems[] = ['label' => 'Statuses', 'url' => ['/status/index']];
}
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
Ejemplo n.º 7
0
    <title><?php 
echo Html::encode($this->title);
?>
</title>

    <?php 
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
?>
<div class="wrap">
    <?php 
$is_admin = ValueHelpers::getRoleValue('Admin');
if (!Yii::$app->user->isGuest) {
    NavBar::begin(['brandLabel' => 'Yii 2 Build <i class="fa fa-plug"></i> Admin', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
} else {
    NavBar::begin(['brandLabel' => 'Yii 2 Build <i class="fa fa-plug"></i>', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
}
$menuItems = [['label' => 'Home', 'url' => ['/site/index']]];
if (!Yii::$app->user->isGuest && Yii::$app->user->identity->role_id >= $is_admin) {
    $menuItems[] = ['label' => 'Users', 'url' => ['user/index']];
    $menuItems[] = ['label' => 'Profiles', 'url' => ['profile/index']];
    $menuItems[] = ['label' => 'Roles', 'url' => ['/role/index']];
    $menuItems[] = ['label' => 'User Types', 'url' => ['/user-type/index']];
    $menuItems[] = ['label' => 'Statuses', 'url' => ['/status/index']];
}
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
Ejemplo n.º 8
0
 /**
  * Finds user by password reset token
  *
  * @param string $token password reset token
  * @return static|null
  */
 public static function findByPasswordResetToken($token)
 {
     if (!static::isPasswordResetTokenValid($token)) {
         return null;
     }
     return static::findOne(['password_reset_token' => $token, 'status' => ValueHelpers::getStatusId('Ativo')]);
 }
Ejemplo n.º 9
0
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
?>

<div class="wrap">
    <?php 
$admin_id = ValueHelpers::getRoleValue('Admin');
if (!Yii::$app->user->isGuest) {
    NavBar::begin(['brandLabel' => 'Yii 2 Build <i class = "fa fa-plug"></i> Admin', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
} else {
    NavBar::begin(['brandLabel' => 'Yii 2 Build <i class = "fa fa-plug"></i>', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
}
$menuItems = [['label' => 'Home', 'url' => ['/site/index']]];
if (!Yii::$app->user->isGuest && Yii::$app->user->identity->role_id >= $admin_id) {
    $menuItems[] = ['label' => 'Users', 'url' => ['user/index']];
    $menuItems[] = ['label' => 'Profiles', 'url' => ['profile/index']];
    $menuItems[] = ['label' => 'Roles', 'url' => ['role/index']];
    $menuItems[] = ['label' => 'User Types', 'url' => ['user-type/index']];
    $menuItems[] = ['label' => 'Statuses', 'url' => ['status/index']];
}
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];