The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
default page for not permitted access
#1
Hello first of all thank you for this script is saving me lots of time, I hope you can help me with an issue I face, I have setup a different login redirection in custom_login_script.php this has been set to ../../access10/main.php I have some apps that live in access10 and some are available for all users and some are not however I have chosen for design reasons to show the links to all users.

I have access10/main.php and access10/advanced.php showing buttons to other functions all in differnet pages, when I am in main.php and click a function with a user who does not have permissions it does nothing just seems to refresh the page, however in when I do the same in access/advanced.php it goes back to access/main.php I have searched the code and even tho I have included some conditionals in custom_login_script.php and in other places I happen not to understand the code fully yet, could you please point me in the right direction?

Again, thank you very much for this app and your help.

Regards

Carlos
  Reply
#2
As always, after you post you find out there is somethig else going on, in the root directory index.php file I have added this code

if($user->isLoggedIn()){
Redirect::to('../../access10/main.php');
}

which sends the user to the main page if the user is logged otherwise displays the login screen.

So it seems the code is sending me back to index.php, where can one add some logic to dinamically change the redirection when a user is trying to access a page the user has no permission to see? or better yet is there a way to show an error in the page to inform the user he does not have access to that page? your help is much appreciated,

Happy new Year

Carlos
  Reply
#3
The more people use userspice, the more people want these kinds of custom scripts in that situation. I'm going to work on something for that. But, you're on the right track that you can totally do your logic on index.php. I have a few ideas I'm going to tinker with.

Happy New Year! Thanks for the feedback.
  Reply
#4
Mundmin,

I would like to have this feature, a static
Code:
accessdenied.php
page or something. How can I output a danger div like the errors with the path name and access denied? I would love tie this into a "Request Access" system! That would be very cool! But definitely another project as you say!

Thank you!
  Reply
#5
I think the trick is going to be that at the bottom of the securePage function over in us_helpers, there is a just a redirect to the homepage. What we need is to pull from another file over in usersc so people can put whatever code they want.

I'm not sure if you know this, Brandin, but any time you do a redirect, you can do a get request at the end and flash a message on the screen. I even do that as a quick way to give user feedback.

So, let's say you have someone complete a form and then want to send them back to a file called cpanel.php, you can do

Redirect::to('cpanel.php?err=Form+complete!+Thank+you+for+your+submission!');

And they will be redirected and have that message flash up on the screen.
  Reply
#6
OH. MY. GOSH. YOU JUST MADE MY LIFE COMPLETE. I am going to start implementing this. I think that would be the easiest solution! Just adding a message!
  Reply
#7
Yeah. I'm adding that as the default to tell people why they got redirected somewhere. One of the huge things is that if you are using php, you refresh the page on submit to make things open and if you redirect, you lose your errors, so this is a great combination. If on success, I redirect with a message and I don't have to refresh the page.
  Reply
#8
So if I redirect someone back to a page I have called
Code:
requestman.php
, with no form just a database pull and table, what do I need to put in to display the "error" message in the danger block? I know on the forms there is a validation successes and errors block, do I just copy this? Will the
Code:
?err
do its job on its own?
  Reply
#9
If you figure that out, let me know. I really want to make the err be a danger and msg be success on that. So if you do it with err now, it will be a danger automatically when you patch the redirect class as soon as I can roll that out.
  Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)