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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:20:34+00:00 2026-06-17T04:20:34+00:00

I am trying to add new custom error in my login, if user_status is

  • 0

I am trying to add new custom error in my login, if user_status is ‘0’ then it should give error, I am proceeding as follow :

UserIdentity.php

const ERROR_USERNAME_INACTIVE=68;
    public function authenticate()
    {
        $user = Users::model()->findByAttributes(array('email'=>$this->username));


        if ($user===null)
        {
            $this->errorCode=self::ERROR_USERNAME_INVALID;
        }
        else if ($user->password !== md5($this->password))
        {
            $this->errorCode=self::ERROR_PASSWORD_INVALID;
        }
        else if($user->user_status !='1')
        {
            $this->errorCode=self::ERROR_USERNAME_INACTIVE;
        }
        else 
        {
            $this->errorCode=self::ERROR_NONE;
            $this->_id = $user->id;
        }
        return !$this->errorCode;
    }

In login.php

case UserIdentity::ERROR_NONE:
                    Yii::app()->user->login($identity);
                    break;
                case UserIdentity::ERROR_USERNAME_INVALID:
                    $this->addError('username','No Such user is associated with us .');
                    break;
                case UserIdentity::ERROR_USERNAME_INACTIVE:
                    $this->addError('user_status','Sorry, this user is not activated yet');
                default: // UserIdentity::ERROR_PASSWORD_INVALID

                    $this->addError('password','Password is incorrect.');
                    break;

Now I am getting problem that when the user_Status is !=1 then it is giving the error correctly but also giving, password incorrect while the password is correct

  • 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-17T04:20:36+00:00Added an answer on June 17, 2026 at 4:20 am

    You forgot to add a break to the last case statement. Without a break the default will be executed.

    ...
        break;
    case UserIdentity::ERROR_USERNAME_INACTIVE:
        $this->addError('user_status','Sorry, this user is not activated yet');
        break;
    default: // UserIdentity::ERROR_PASSWORD_INVALID
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to add an element to a database and then return a new
I was trying to add some custom error messages to a form like this
Im new to asp.net mvc. I'm trying add new model class but it got
I'm trying to add a new nova-compute node (KUubuntu 12.04) to my single node
I am trying to add a new record to my internal table and this
I am trying to add a new column into an SQLiteDatabase but every time
I'm trying to add a new JDBC Data Source connect to hive in oracle
I am trying to add a new menu item to Eclipse's popupmenus. It really
I'm trying to add a new ADO.Net Entity Data Model to an MVC project
I'm trying to add a variable within a new variable. My first variable is:

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.