PHP-Login icon indicating copy to clipboard operation
PHP-Login copied to clipboard

Defining roles and the pages they get redirected to

Open dbavosi opened this issue 6 years ago • 10 comments

I'm trying to set up a few different roles for users, various roles for standard users. When 1 type of new role logs in, I would like them to see a different page. There are pages, like page_2, page_3, etc... which is nice, but how do I attach roles to new pages so I can create page_6, page_7 and so on?

dbavosi avatar Jun 14 '18 20:06 dbavosi

You’d want to use the $auth object that’s spawned in the pagehead file on page load and use the “hasRole” method. This returns true or false based on if the current user has the method that you pass it. From there you can redirect (or conditionally display content or whatever else you want) based on if it’s true or false.

Sent with GitHawk

therecluse26 avatar Jun 14 '18 23:06 therecluse26

Interesting. I'm trying that. In the mean time, when a user logs in, they click the login button, and get looped back to /login/index.php, but shouldn't it go to /index.php without the login? The user's session is valid and can navigate by the menu, it's just the login process. Where does that get set? I checked my DB and the base URL there is correct.

dbavosi avatar Jun 15 '18 18:06 dbavosi

I've never had it loop back to the login page, and I'm unable to replicate the problem myself now. Could you list out the steps for me that you go through to cause that to happen?

therecluse26 avatar Jun 16 '18 02:06 therecluse26

I go to the login page, log in and it loops back to the login page. The URL doesn't change, but the top nav bar shows me logged in.

dbavosi avatar Jun 18 '18 14:06 dbavosi

What webserver are you running? Also, what operating system/version?

All I can think off of the top of my head is some sort of configuration issue with your webserver or redirect rule messing things up. The PHP script is set to automatically redirect to the homepage if the login page is accessed while the user is already logged in.

therecluse26 avatar Jun 18 '18 16:06 therecluse26

It's a shared linux box. Kinda all I can dig up from the cpanel. Composer barely ran on my machine to set up the vendor file. I had to pull in the jquery and the bootstap css files manually. I

dbavosi avatar Jun 18 '18 17:06 dbavosi

Also, thank you for your help here! It is truly appreciated!

dbavosi avatar Jun 18 '18 17:06 dbavosi

Ah, I hate those shared servers, honestly. They always seem to cause all kinds of weird problems, and you have no control over the underlying system to solve them. Have you thought about using a cheap VPS provider instead like vultr or digitalocean? I'd highly recommend going for one of those over a shared hosting service.

therecluse26 avatar Jun 19 '18 04:06 therecluse26

No problem! Happy to help! Good luck to you :)

On Mon, Jun 18, 2018 at 1:51 PM, d_diddy [email protected] wrote:

Also, thank you for your help here! It is truly appreciated!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/therecluse26/PHP-Login/issues/199#issuecomment-398139828, or mute the thread https://github.com/notifications/unsubscribe-auth/AH24AsrJobN7WdS7iFpcgeOOiEba1lvQks5t9-itgaJpZM4Uol3D .

therecluse26 avatar Jun 19 '18 19:06 therecluse26

HI, I'm facing the same problem here, after login i'm still on the /login/index.php istead of /index.php. Any idea? Thanks schermata-2018-08-13-alle-12 31 43 z

uomopalese avatar Aug 13 '18 10:08 uomopalese