Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7575537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:42:38+00:00 2026-05-30T16:42:38+00:00

When isAuthorized = false the user is redirected to ‘/’ is there a way

  • 0

When isAuthorized = false the user is redirected to ‘/’ is there a way to change this. I want to redirect to the user dashboard (/users/dashboard) with a flash message saying ‘Access prohibited’ or something like that.

Cheers!

public function isAuthorized($user) {
    if (isset($user['role']) && $user['role'] === 'admin') {
        return true; //Admin can access every action
    }
    return false; // The rest don't
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:42:38+00:00Added an answer on May 30, 2026 at 4:42 pm

    If your isAuthorised variable is being evaluated in your controller.

    You can call the redirect function.

    $this->redirect(array('controller' => 'users', 'action' => 'dashboard'));
    

    If you are actually inside the users controller allready, just call

    $this->redirect(array('action' => 'dashboard'));
    

    If not, where are you checking the isAuthorised value?

    This is not an ideal solution. However it seems that there is no way to do this with the current built in AuthComponent

    Edit: Added code as an example.

    public function isAuthorized($user) {
    if (parent::isAuthorized($user)) {
        return true;
    }
    // Authorised actions
    if (in_array($this->action, array('dashboard'))) {
        return true;
    }
    // Will break out on this call
    $this->redirect(array('controller' => 'users', 'action' => 'dashboard'));
    return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to redirect the user to a custom error page when s/he is
This is my authorize class which overrides the default AurthorizeCore, I'd like to redirect
I am making a users profile page and if i route it like this
I have this custom authorization class to check if a user is an admin:
Check this: function beforeFilter() { $this->Auth->authorize = 'controller'; $this->Auth->allow('delete'); } function isAuthorized() { if
I use dotnetOpenAuth. I want to request authorization to the user's gamil. Do I
I want to prevent banned users from logging in to the site and give
Is there a way to query for all access_tokens or page_ids that an app
is there a way to get the list of currently listed developers on a
How does the Authorize Tag determine if the user is authorized or not? Like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.