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 8713735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:24:38+00:00 2026-06-13T05:24:38+00:00

Problem: I want to show different error messages to user based on user status

  • 0

Problem: I want to show different error messages to user based on user status on login (using ajax). For ex: If the user status is pending, I want to show one message, or else if the user status is disabled, I want to show another message. Only active user should be able to login.

After some searching found that I can use

  1. identify method

    or

  2. I should use write my conditions inside “if
    ($this->Auth->login())
    ” condition in my login method.

If I use 1st method in custom component (which will extend auth), hope it can only return true or false, right ? Can it set error messages and return, so that I can get it from my controller ?

If I use 2nd method after allowing the user to login I should check the status and if it is not active, I should remove the login credentials from Auth/Session. how can I do that ? Is this a good method ?

Any other better solution ? Im using cakephp2.0

  • 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-13T05:24:39+00:00Added an answer on June 13, 2026 at 5:24 am

    I would create a class extending from BaseAuthenticate for your users and set this up within your AppController.

    public $components = array(
        'Session',
        'Auth' => array(
            'loginRedirect' => ..... ,
            'logoutRedirect' => ..... ,
            'loginAction' => ..... ,
            'authenticate' => array('YourUsers'),
        )
    );
    

    And then create the class

    <?php
    App::uses('BaseAuthenticate', 'Controller/Component/Auth');
    
    class YourUsersAuthenticate extends BaseAuthenticate {
    
        public function authenticate(CakeRequest $request, CakeResponse $response) {
            // your code goes in here
        }
    }
    

    You can return false from within the authenticate to deny the user access or can return an object on success that will get stored in $this->Auth->user which you can interogate later.

    If you get stuck, the CookBook has a lot of detail about this.

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

Sidebar

Related Questions

My problem is i want to show emailids of users who are currently members
My problem is pretty common. I want to show some loading stuff while the
My Objective is to use h:messages to convey user - error and confirmation messages.
I have a simple, real life problem I want to solve using an OO
Problem I want to use the interactive debugger with IntelliJ. Unfortunately, I can't convince
Problem: I want to add headers in the middle of a gridview databind. I
Problem: I want to list n number of games from each genre (order not
Problem: I want my unicode characters to be stored on disk as (rather tan
Problem: I want disparate sections of my code to be able to access a
Problem I want to create an application that can be extended somehow by programmers.

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.