public function safeUp() { $user = new \common\models\User(); $user->username = '******'; $user->email = '*****@*****.**'; $user->setPassword('demo'); $user->generateAuthKey(); $user->generatePasswordResetToken(); $user->save(); }
public function up() { $tableOptions = null; if ($this->db->driverName === 'mysql') { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB'; } $this->createTable('{{%user}}', ['id' => Schema::TYPE_PK, 'username' => Schema::TYPE_STRING . ' NOT NULL ', 'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL', 'password_hash' => Schema::TYPE_STRING . ' NOT NULL', 'password_reset_token' => Schema::TYPE_STRING, 'email' => Schema::TYPE_STRING . ' NOT NULL', 'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10', 'created_at' => Schema::TYPE_INTEGER . ' NOT NULL', 'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL'], $tableOptions); $user = new \common\models\User(); $user->username = '******'; $user->email = '*****@*****.**'; $user->generateAuthKey(); $user->setPassword('demo'); return $user->insert(); }
public function signup() { if ($this->validate()) { $user = new \common\models\User(); $user->username = $this->username; $user->email = $this->email; $user->setPassword('123456'); $user->generateAuthKey(); $user->status = 10; if ($user->save()) { return $user; } } return null; }
public function save($runValidation = true, $attributeNames = NULL) { $is = false; try { if ($this->validate()) { $user = new \common\models\User(); $user->username = $this->username; $user->email = $this->email; if ($this->isNewRecord) { $user->setPassword($this->password); $user->generateAuthKey(); $user->status = $this->status == 1 ? 10 : 0; if ($user->save()) { $this->save_assignment($user->id); } } } $is = true; } catch (Exception $e) { echo $e->getMessage(); } return true; }
private function setRoot() { $model = \common\models\User::find()->andWhere('id = 1')->one(); if (empty($model)) { $model = new \common\models\User(); $model->id = 1; $model->username = '******'; $model->password = '******'; $model->email = '*****@*****.**'; $model->status = 10; $model->language = 'en-US'; $model->setPassword($model->password); $model->generateAuthKey(); $model->save(false); } }