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

  • SEARCH
  • Home
  • 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 8705019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:15:02+00:00 2026-06-13T03:15:02+00:00

I have a number of authentication components that extend the BaseAuthenticate class. These are

  • 0

I have a number of authentication components that extend the BaseAuthenticate class. These are setup in the AppController in the normal way.

Is it possible for an authentication component to alter the AuthComponent’s loginRedirect variable?

To clarify the situation, one of my authentication components looks at a certain subset of users. It checks to see if the credentials are valid before checking to see if that person has any outstanding invoices. Depending on the outstanding value, I’d like to redirect the user to a given page or block them out altogether.

Thanks

  • 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-06-13T03:15:04+00:00Added an answer on June 13, 2026 at 3:15 am

    A big thanks to @jerermyharris for pushing me in the right direction. Here goes with what I ended up doing.

    1. Extended the AuthComponent

        App::uses('AuthComponent', 'Controller/Component');
    
        class MyAuthComponent extends AuthComponent {
    
          var $components = array('Session'); 
    
          public function identify(CakeRequest $request, CakeResponse $response) {
            if (empty($this->_authenticateObjects)) {
                $this->constructAuthenticate();
            }
            foreach ($this->_authenticateObjects as $auth) {
                $result = $auth->authenticate($request, $response);
                if (!empty($result) && is_array($result)) {
                    if(isset($result['Redirect']))
                    {
                        $this->Session->write('Auth.redirect', $result['Redirect']);            
                    }
                    return $result;
                }
            }
            return false;
          }
        }
    

    2. Add this the AppController components

    public $components = array(
            'Auth' => array(
                'className' => 'MyAuth',
            )
    );
    

    Add this bit around whatever other definitions you have for your AuthComponent.

    3. Return a redirect from your authentication component

    App::uses('BaseAuthenticate', 'Controller/Component/Auth');
    
    class TutorAuthenticate extends BaseAuthenticate {
    
        public function authenticate(CakeRequest $request, CakeResponse $response) {
            $user = ...... // However you authenticate your user
            $user['Redirect'] = "http://example.com";
            return $user;
        }
    }
    

    So now if you want to redirect based on the user you can just add it in, if you don’t then cake will obey the directives you set up in AppController.

    Wow, that seems like I’ve had to do loads extra, but it’s the right thing to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Due to our clients authentication and network topology we have a number of Windows
I have a number input that should trigger jQuery on every change. To do
We have a number of data objects that realize INotifyPropertyChanged to allow for WPF
I have a number of draggable images that I want to clone and then
I have a number of text input elements that when its values are changed,
I have an application that can be used without authentication on computers in public
Let's say we have an application that has a number of features and each
I have an asp .net webforms app that uses forms authentication. For a small
I have a django project that uses a postgres db with a number of
A number of Rails 2.3 apps are using Restful Authentication but that plugin seems

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.