common/controllers/base/Controller.php
protected function checkHome() {

		// Send user to home if already logged in
		if ( !Yii::$app->user->isGuest ) {

			$user		= Yii::$app->user->getIdentity();
			$role		= $user->role;
			$storedLink	= Url::previous( CoreGlobal::REDIRECT_LOGIN );

			$siteId		= Yii::$app->core->getSiteId();

			$siteMember = Yii::$app->factory->get( 'siteMemberService' )->getBySiteIdUserId( $siteId, $user->id );

			// Auto-Register site member
			if( !isset( $siteMember ) ) {

				Yii::$app->factory->get( 'siteMemberService' )->create( $user );
			}

			// Redirect user to stored link on login
			if( isset( $storedLink ) ) {

				Yii::$app->response->redirect( $storedLink )->send();
			}
			// Redirect user having role to home
			else if( isset( $role ) ) {

				// Switch according to app id
				$appAdmin		= Yii::$app->core->getAppAdmin();
				$appFrontend	= Yii::$app->core->getAppFrontend();

				// User is on admin app
				if( Yii::$app->id === $appAdmin && isset( $role->adminUrl ) ) {

					Yii::$app->response->redirect( [ "/$role->adminUrl" ] )->send();
				}
				// User is on frontend app
				else if( Yii::$app->id === $appFrontend && isset( $role->homeUrl ) ) {

					Yii::$app->response->redirect( [ "/$role->homeUrl" ] )->send();
				}
				// Redirect user to home set by app config
				else {

					Yii::$app->response->redirect( [ Yii::$app->core->getLoginRedirectPage() ] )->send();
				}
			}
			// Redirect user to home set by app config
			else {

				Yii::$app->response->redirect( [ Yii::$app->core->getLoginRedirectPage() ] )->send();
			}
		}
	}
protected function checkHome() {

		// Send user to home if already logged in
		if ( !Yii::$app->user->isGuest ) {

			$user		= Yii::$app->user->getIdentity();
			$role		= $user->role;
			$storedLink	= Url::previous( CoreGlobal::REDIRECT_LOGIN );

			$siteId		= Yii::$app->core->getSiteId();

			$siteMember = Yii::$app->factory->get( 'siteMemberService' )->getBySiteIdUserId( $siteId, $user->id );

			// Auto-Register site member
			if( !isset( $siteMember ) ) {

				Yii::$app->factory->get( 'siteMemberService' )->create( $user );
			}

			// Redirect user to stored link on login
			if( isset( $storedLink ) ) {

				Yii::$app->response->redirect( $storedLink )->send();
			}
			// Redirect user having role to home
			else if( isset( $role ) ) {

				// Switch according to app id
				$appAdmin		= Yii::$app->core->getAppAdmin();
				$appFrontend	= Yii::$app->core->getAppFrontend();

				// User is on admin app
				if( Yii::$app->id === $appAdmin && isset( $role->adminUrl ) ) {

					Yii::$app->response->redirect( [ "/$role->adminUrl" ] )->send();
				}
				// User is on frontend app
				else if( Yii::$app->id === $appFrontend && isset( $role->homeUrl ) ) {

					Yii::$app->response->redirect( [ "/$role->homeUrl" ] )->send();
				}
				// Redirect user to home set by app config
				else {

					Yii::$app->response->redirect( [ Yii::$app->core->getLoginRedirectPage() ] )->send();
				}
			}
			// Redirect user to home set by app config
			else {

				Yii::$app->response->redirect( [ Yii::$app->core->getLoginRedirectPage() ] )->send();
			}
		}
	}
protected function checkHome ( ) { // Send user to home if already logged in if ( ! Yii :: $ app -> user -> isGuest ) { $ user = Yii :: $ app -> user -> getIdentity ( ) ; $ role = $ user -> role ; $ storedLink = Url :: previous ( CoreGlobal :: REDIRECT_LOGIN ) ; $ siteId = Yii :: $ app -> core -> getSiteId ( ) ; $ siteMember = Yii :: $ app -> factory -> get ( 'siteMemberService' ) -> getBySiteIdUserId ( $ siteId , $ user -> id ) ; // Auto-Register site member if ( ! isset ( $ siteMember ) ) { Yii :: $ app -> factory -> get ( 'siteMemberService' ) -> create ( $ user ) ; } // Redirect user to stored link on login if ( isset ( $ storedLink ) ) { Yii :: $ app -> response -> redirect ( $ storedLink ) -> send ( ) ; } // Redirect user having role to home else if ( isset ( $ role ) ) { // Switch according to app id $ appAdmin = Yii :: $ app -> core -> getAppAdmin ( ) ; $ appFrontend = Yii :: $ app -> core -> getAppFrontend ( ) ; // User is on admin app if ( Yii :: $ app -> id === $ appAdmin && isset ( $ role -> adminUrl ) ) { Yii :: $ app -> response -> redirect ( [ "/$role->adminUrl" ] ) -> send ( ) ; } // User is on frontend app else if ( Yii :: $ app -> id === $ appFrontend && isset ( $ role -> homeUrl ) ) { Yii :: $ app -> response -> redirect ( [ "/$role->homeUrl" ] ) -> send ( ) ; } // Redirect user to home set by app config else { Yii :: $ app -> response -> redirect ( [ Yii :: $ app -> core -> getLoginRedirectPage ( ) ] ) -> send ( ) ; } } // Redirect user to home set by app config else { Yii :: $ app -> response -> redirect ( [ Yii :: $ app -> core -> getLoginRedirectPage ( ) ] ) -> send ( ) ; } } }
The method check whether user is logged in and send to respective home page.
The method check whether user is logged in and send to respective home page .