Пример #1
0
    public function actionIndex()
    {
        if(Auction::$app->user->isGuest){
            Auction::warning('Guest User :: Redirecting to Login Page');
            $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('site/login'));
        }
        else {
            switch (Auction::$app->session->get('user.role')) {
                case DatabaseHelper::ADMIN :
                    Auction::info('Redirecting to Admin Module');
                    $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('admin'));
                    break;

                case DatabaseHelper::DEALER :
                    Auction::info('Redirecting to Dealer Module');
                    $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('dealer/profile'));
                    break;

                case DatabaseHelper::COMPANY_USER :
                    Auction::info('Redirecting to Company User Module');
                    $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('company/profile'));
                    break;

                case DatabaseHelper::COMPANY_ADMIN :
                    Auction::info('Redirecting to Company Admin Module');
                    $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('company/info'));
                    break;

                default :
                    $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('site/login'));
                    Auction::warningLog('Logging Out due to Unknown Role Created On Server',['role' => Auction::userRole()]);
            }
        }
    }
Пример #2
0
    /**
     * Action to Perform User Logout
     * Will go Home If User is already logout
    */
    public function actionIndex()
    {

        if(Auction::$app->user->isGuest){
            Auction::warning('User Already is Logged Out');
            return $this->goHome();
        }

        Auction::$app->user->logout();

        //Setting Logger @info
        $message = Auction::loggerMessageFormat('User logout SuccessFully' ,[
            'class' => __CLASS__ ,
            'function' => __METHOD__,
            'username' => Auction::$app->session->get('user.name'),
            'role' => Auction::$app->session->get('user.role'),
            'userId' => Auction::$app->user->id
        ]);
        Auction::info($message,Auction::LOGGER_FRONTEND_CATEGORY);

        return $this->goHome();
    }