Answer the question
In order to leave comments, you need to log in
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);
Answer the question
In order to leave comments, you need to log in
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'),
),
);
}
}
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 questionAsk a Question
731 491 924 answers to any question