jeudi 21 septembre 2017

How can I enable a certain route access only when a certain condition is true?

GOAL

I'm trying to block my main login page base on a flag of my .env file. I'm not sure if this is the right approach.


Steps

In my .env I've added

LOGIN_PAGE=true

Then in my route file

I add that if check

if(env('LANDING_PAGE') == true){

    Route::get('/',['as' => 'login', 'uses'=>'AuthController@getSignIn']);
    Route::post('/', 'AuthController@postSignIn');
}


Result

LOGIN_PAGE=fasle

I go to my log-in page, I got 404 Page not found which is good.

LOGIN_PAGE=true

I go to my log-in page, I still got 404 Page not found which is not good. I should see my log-in page.

What did I forget ? How would one and go about and #GOAL

I'm trying to block my main login page base on a flag of my .env file. I'm not sure if this is the right approach.


Steps

In my .env I've added

LOGIN_PAGE=true

Then in my route file

I add that if check

if(env('LANDING_PAGE') == true){

    Route::get('/',['as' => 'login', 'uses'=>'AuthController@getSignIn']);
    Route::post('/', 'AuthController@postSignIn');
}


Result

LOGIN_PAGE=fasle

I go to my log-in page, I got 404 Page not found which is good.

LOGIN_PAGE=true

I go to my log-in page, I still got 404 Page not found which is not good. I should see my log-in page.

What did I forget ? How would one and go about and enable a certain route access only when a certain condition is true ?

Any hints / suggestions will be much appreciated !



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire