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]); }
public function actionDelete($id) { $user = User::find()->id($id)->one(); if ($user && $user->delete()) { return $this->redirect(['user/index']); } throw new ForbiddenHttpException('Access Denied.'); }
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.'); } }
<?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']);