jasonhinkle / phreeze

Phreeze Framework for PHP
http://phreeze.com/
GNU Lesser General Public License v2.1
377 stars 207 forks source link

Like putting the login page at the beginning so that the user only has access after logging in. #261

Open jailton2018 opened 7 years ago

jailton2018 commented 7 years ago

Hi, I'd like to know how to put the login page in the beginning so that the user only has access to log on first. Thank you very much in advance!

Esysc commented 7 years ago

Hello, there are some examples on closed issues , look at #78 . I personally did it more simple, just put the logic in index.php checking if valid user is logged, if not redirect to login.php . I use LDAP in my environment, then after validation redirect to the requested page.

jailton2018 commented 7 years ago

Hi, thanks for the help. If you could pass the code of this solution that you found, I am a beginner with php and mvc. Thank you!

Esysc commented 7 years ago

Look here https://github.com/Esysc/SPOT/blob/master/provisioning/login.php It's a very basic example. You have the login form and validation then all pass through the session . The index.php check a valid session before to redirect. You have in the same direct ory the original login that refers to a dB users table. 

jailton2018 commented 7 years ago

Hi, Let me see if I understand, I have to change this code in the secureExample.php page? For that page that is responsible for the login, correct?

Esysc commented 7 years ago

Hello, you can use the example if you prefer and look orders threads. I simply check a session variable, not so elegant, but the app runs on corporate. Look in index.php, if the session is not set redirect to login.php . This script validate the user then redirect to the requested url. I put the check in index.php because every routed url pass there.

jailton2018 commented 7 years ago

Hello I copied the file login.php Example Its and I pasted index and it does not give place that I deleted or code that was in it to leave it or to make Example Its, redirects IT to a page of login of Its Example, to put more I COME does not PASSWORD That phreeze, DO NOT give is more right.

Esysc commented 7 years ago

Don't know if I have understood., but the code is just an example, cannot run in your environment. I proposed you just to give a look for inspiration. Bit not copy and paste as is

jailton2018 commented 7 years ago

Ok, I got confused I thought this project you were doing was using phreeze frameworks, because it's a good framework for beginners, but the bad part is we do not have much information about it. But I thank you for your attention and help!