Question

In my application,i want to de-activate the existing user and able to create new user with same username and email address.I know,kohana have set username and email address as unique i created a column called is_deactivated in User table and setting a flag to that.If the user is deactivated,the flag set to zero,else the flag is "1".I written an separate function for validation of unique username and email address with reference to is_deactivated flag.If the flag is "0",validation will ignore the existing username and email address and user able to create new user with same existing username and password.New username is created with same username.After signup,it is taking me to existing de-activated user account, instead of fresh new account.But if i login with same username and password,it is taking me to existing de-activated account.In login,i had validated with this is_deactivated flag with 1.

for creating new user with same username i had commented the below lines from User.php,

/var/www/html/zergid/modules/orm/classes/Model/Auth/User.php

public function rules()
    {
        return array(
//          'username' => array(
//              array('not_empty'),
//              array('max_length', array(':value', 32)),
//              array(array($this, 'unique'), array('username', ':value')),
//          ),
            'password' => array(
                array('not_empty'),
            ),
//          'email' => array(
//              array('not_empty'),
//              array('email'),
//              array(array($this, 'unique'), array('email', ':value')),
//          ),
        );
    }

Need help to how to login to newly created account and not existing de-activated account.

Thanks

Was it helpful?

Solution

When a user is login to site,it checks the username,password.There i am checking my flag condition.See the code below

/var/www/html/Kohana/modules/orm/classes/Kohana/Auth/ORM.php

protected function _login($user, $password, $remember)
    {
        if ( ! is_object($user))
        {
            $username = $user;

            // Load the user
            $user = ORM::factory('User');
            $user->where($user->unique_key($username), '=', $username)->and_where('is_deleted','=',1)->find(); //checking the flag here(->and_where('is_deleted','=',1))
        }

Worked!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top