public function actionLogout() { $email = Yii::$app->user->identity->email; Yii::info("Logging out user [{$email}]", __CLASS__); $event = Event::createUserEvent(Yii::$app->user->identity); $this->trigger(self::EVENT_BEFORE_LOGOUT, $event); Yii::$app->user->logout(); Yii::info("User [{$email}] is successfuly logged out", __CLASS__); $this->trigger(self::EVENT_AFTER_LOGOUT, $event); return $this->goHome(); }
/** * Performs the actual user registration by validation the data and persisting the user. * * @param UserModel $model * @return bool */ public function register(UserModel $model) { Yii::info("Registering user [{$model->email}]", __CLASS__); if ($this->enableConfirmation == false) { $model->confirmed_on = time(); } $event = Event::createUserEvent($model); $this->trigger(self::EVENT_BEFORE_REGISTER, $event); Yii::info("Saving user [{$model->email}] to the database", __CLASS__); if ($model->save()) { Yii::info("User [{$model->email}] successfuly registered!", __CLASS__); // Raise event that the user is persisted $this->trigger(self::EVENT_AFTER_REGISTER, $event); //Add confirmation token(if enabled) and notify user if ($this->enableConfirmation) { Yii::info("Creating token of user [{$model->email}]", __CLASS__); $token = Yii::createObject(['class' => Token::className(), 'type' => Token::TYPE_CONFIRMATION]); $token->link('user', $model); Yii::info("Sending confirmation email to [{$model->email}]", __CLASS__); $this->getNotificator()->sendConfirmationMessage($model, $token); } return true; } Yii::error("An error occurred while registering user [{$model->email}][{$model->register_ip}].\n" . VarDumper::dumpAsString($model->getErrors()), __CLASS__); return false; }