Ejemplo n.º 1
0
 public function register()
 {
     if (!$this->validate()) {
         return false;
     }
     $user = new User(['username' => $this->username, 'password' => $this->password]);
     $profile = $user->create(Profile::className(), ['nickname' => $this->username, 'display_name' => $this->username]);
     $email = $user->create(Email::className(), ['email' => $this->email]);
     return $user->register([$profile, $email]);
 }
Ejemplo n.º 2
0
 public function actionDelete($id)
 {
     $user = User::find()->id($id)->one();
     if ($user && $user->delete()) {
         return $this->redirect(['user/index']);
     }
     throw new ForbiddenHttpException('Access Denied.');
 }
Ejemplo n.º 3
0
 private function findIdentity($username)
 {
     switch ($this->judgeUsernameType($username)) {
         case static::ACCOUNT_TYPE_STRING:
             return User::findIdentity($username);
         case static::ACCOUNT_TYPE_EMAIL:
             return User::findIdentityByEmail($username);
         default:
             throw new \yii\base\NotSupportedException('Not recognized account type.');
     }
 }
Ejemplo n.º 4
0
<?php

/**
 *  _   __ __ _____ _____ ___  ____  _____
 * | | / // // ___//_  _//   ||  __||_   _|
 * | |/ // /(__  )  / / / /| || |     | |
 * |___//_//____/  /_/ /_/ |_||_|     |_|
 * @link http://vistart.name/
 * @copyright Copyright (c) 2016 vistart
 * @license http://vistart.name/license/
 */
use yii\widgets\ListView;
use yii\data\ActiveDataProvider;
use rhopress\models\User;
$dataProvider = new ActiveDataProvider(['query' => User::find(), 'pagination' => ['pageSize' => 20]]);
echo ListView::widget(['dataProvider' => $dataProvider, 'itemView' => 'index/user']);