common/controllers/SiteController.php
public function actionActivateAccount( $token, $email ) {

		// Send user to home if already logged in
		$this->checkHome();

		// Unset Flash Message
		Yii::$app->session->setFlash( CoreGlobal::FLASH_GENERIC, null );

		$model = new ResetPassword();

		$model->email = $email;

		// Load and Validate Form Model
		if( $model->load( Yii::$app->request->post(), 'ResetPassword' ) && $model->validate() ) {

			$coreProperties = $this->getCoreProperties();

			$user = $this->userService->getByEmail( $model->email );

			// If valid user found
			if( isset( $user ) ) {

				// Activate User
				if( $this->userService->reset( $user, $token, $model, true ) ) {

					// Send Activation Mail
					Yii::$app->coreMailer->sendActivateUserMail( $user );

					// Set Success Message
					Yii::$app->session->setFlash( CoreGlobal::FLASH_GENERIC, Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_ACCOUNT_ACTIVATE ) );

					// Auto Login
					if( $coreProperties->isAutoLogin() ) {

						Yii::$app->user->login( $user, 3600 * 24 * 30 );
					}

					return $this->render( CoreGlobal::PAGE_ACCOUNT_ACTIVATE, [ CoreGlobal::MODEL_GENERIC => $model, 'activated' => true ] );
				}

				// Set Failure Message
				Yii::$app->session->setFlash( CoreGlobal::FLASH_GENERIC, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_ACCOUNT_CONFIRM ) );

				return $this->render( CoreGlobal::PAGE_ACCOUNT_ACTIVATE, [ CoreGlobal::MODEL_GENERIC => $model, 'activated' => false ] );
			}
			else {

				// Set Failure Message
				Yii::$app->session->setFlash( CoreGlobal::FLASH_GENERIC, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_USER_NOT_EXIST ) );
			}
		}

		return $this->render( CoreGlobal::PAGE_ACCOUNT_ACTIVATE, [ CoreGlobal::MODEL_GENERIC => $model ] );
	}
public function actionActivateAccount( $token, $email ) {

		// Send user to home if already logged in
		$this->checkHome();

		// Unset Flash Message
		Yii::$app->session->setFlash( CoreGlobal::FLASH_GENERIC, null );

		$model = new ResetPassword();

		$model->email = $email;

		// Load and Validate Form Model
		if( $model->load( Yii::$app->request->post(), 'ResetPassword' ) && $model->validate() ) {

			$coreProperties = $this->getCoreProperties();

			$user = $this->userService->getByEmail( $model->email );

			// If valid user found
			if( isset( $user ) ) {

				// Activate User
				if( $this->userService->reset( $user, $token, $model, true ) ) {

					// Send Activation Mail
					Yii::$app->coreMailer->sendActivateUserMail( $user );

					// Set Success Message
					Yii::$app->session->setFlash( CoreGlobal::FLASH_GENERIC, Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_ACCOUNT_ACTIVATE ) );

					// Auto Login
					if( $coreProperties->isAutoLogin() ) {

						Yii::$app->user->login( $user, 3600 * 24 * 30 );
					}

					return $this->render( CoreGlobal::PAGE_ACCOUNT_ACTIVATE, [ CoreGlobal::MODEL_GENERIC => $model, 'activated' => true ] );
				}

				// Set Failure Message
				Yii::$app->session->setFlash( CoreGlobal::FLASH_GENERIC, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_ACCOUNT_CONFIRM ) );

				return $this->render( CoreGlobal::PAGE_ACCOUNT_ACTIVATE, [ CoreGlobal::MODEL_GENERIC => $model, 'activated' => false ] );
			}
			else {

				// Set Failure Message
				Yii::$app->session->setFlash( CoreGlobal::FLASH_GENERIC, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_USER_NOT_EXIST ) );
			}
		}

		return $this->render( CoreGlobal::PAGE_ACCOUNT_ACTIVATE, [ CoreGlobal::MODEL_GENERIC => $model ] );
	}
public function actionActivateAccount ( $ token , $ email ) { // Send user to home if already logged in $ this -> checkHome ( ) ; // Unset Flash Message Yii :: $ app -> session -> setFlash ( CoreGlobal :: FLASH_GENERIC , null ) ; $ model = new ResetPassword ( ) ; $ model -> email = $ email ; // Load and Validate Form Model if ( $ model -> load ( Yii :: $ app -> request -> post ( ) , 'ResetPassword' ) && $ model -> validate ( ) ) { $ coreProperties = $ this -> getCoreProperties ( ) ; $ user = $ this -> userService -> getByEmail ( $ model -> email ) ; // If valid user found if ( isset ( $ user ) ) { // Activate User if ( $ this -> userService -> reset ( $ user , $ token , $ model , true ) ) { // Send Activation Mail Yii :: $ app -> coreMailer -> sendActivateUserMail ( $ user ) ; // Set Success Message Yii :: $ app -> session -> setFlash ( CoreGlobal :: FLASH_GENERIC , Yii :: $ app -> coreMessage -> getMessage ( CoreGlobal :: MESSAGE_ACCOUNT_ACTIVATE ) ) ; // Auto Login if ( $ coreProperties -> isAutoLogin ( ) ) { Yii :: $ app -> user -> login ( $ user , 3600 * 24 * 30 ) ; } return $ this -> render ( CoreGlobal :: PAGE_ACCOUNT_ACTIVATE , [ CoreGlobal :: MODEL_GENERIC => $ model , 'activated' => true ] ) ; } // Set Failure Message Yii :: $ app -> session -> setFlash ( CoreGlobal :: FLASH_GENERIC , Yii :: $ app -> coreMessage -> getMessage ( CoreGlobal :: ERROR_ACCOUNT_CONFIRM ) ) ; return $ this -> render ( CoreGlobal :: PAGE_ACCOUNT_ACTIVATE , [ CoreGlobal :: MODEL_GENERIC => $ model , 'activated' => false ] ) ; } else { // Set Failure Message Yii :: $ app -> session -> setFlash ( CoreGlobal :: FLASH_GENERIC , Yii :: $ app -> coreMessage -> getMessage ( CoreGlobal :: ERROR_USER_NOT_EXIST ) ) ; } } return $ this -> render ( CoreGlobal :: PAGE_ACCOUNT_ACTIVATE , [ CoreGlobal :: MODEL_GENERIC => $ model ] ) ; }
The users added by site admin can be activated by providing valid token and email. If
activation link is still valid, user will be activated.
The users added by site admin can be activated by providing valid token and email . If activation link is still valid user will be activated .