B
B
betmenik2018-01-15 16:18:22
Kohana
betmenik, 2018-01-15 16:18:22

Authorization by username and password kohana 3.3, how not to respect email?

Hello!
Help please deal with the problem.
In general, I made a registration where the main and unique data are in the username cell, that is, the login. Email does not play any role other than just information.
That is, users with different usernames but with the same email can register.
The problem arose during authorization, without errors and problems, the user who first registered under a duplicate email address is authorized. Subsequent users with the same email address can no longer log in normally, records appear in the "user_tokens" table, but the framework error appears in the browser itself associated with "ORM_Validation_Exception". More specifically, it refers to this line:

$exception = new ORM_Validation_Exception($this->errors_filename(), $array);

I don’t understand what to do next ... Let there be at least 100 users with the same email address, but they must enter the site under username and password.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Kuznetsov, 2018-01-16
@DarkRaven

Notice the Model_Auth_User class (modules\orm\classes\Model\Auth\User.php).
These are the user model validation rules. Change them and you should be fine.
PS I didn't see your comment.
By the way, these rules can be overridden through your model - you do not need to make changes to the system module.
In the application\classes\Model folder, create the User.php file.
Write something like this there:

<?php defined('SYSPATH') or die('No direct script access.');

class Model_User extends Model_Auth_User
{
    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'),
      ),
        );
    }
    
}

B
Boris Korobkov, 2018-01-15
@BorisKorobkov

Option 1. Make the email unique, prevent re-registration with the same email (instead, restore the first registration). If there are already duplicates, you need to merge them into one.
Option 2. Change user_tokens so that it does not take into account email.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question