Answer the question
In order to leave comments, you need to log in
How to change the basic login to work with data from the database in yii2?
I wrote my controller and model for registration, because registration on my project is complicated, in several steps, a lot of data, different types of registration. Those. ready-made solutions could not pull.
But I would not want to bother with authorization, because. e-mail and password from the database are used for authorization.
I can’t pull ready-made solutions / modules, because registration is ready.
But it would be quite a solution to remake the basic template to work from the database.
But I don’t want to figure it out yet, because it’s not a fact that it will be faster. But I would be happy to accept a link to an article \ manual where this is implemented, so that I can read it and quickly do it. Does anyone know similar?
Answer the question
In order to leave comments, you need to log in
In general stuck with crutches in the existing code.
in the findIdentity($id) method, by this id, I look for a record about the user, form an array, as a standard one, and override it with the values of this array. This method checks the logged in user.
And for validation, I did the same in findByUsername($username)
Well, in the validatePassword($password) method, I had to add md5 password generation, that's all.
class User extends ActiveRecord implements IdentityInterface {
public static function tableName() {
return 'users';
}
public static function findIdentity($id) {
return static::findOne($id);
}
public static function findIdentityByAccessToken($token, $type = null) {
return static::findOne(['access_token' => $token]);
}
public function getId() {
return $this->getPrimaryKey();
}
public function getAuthKey() {
return $this->auth_key;
}
public function validateAuthKey($authKey) {
return $this->getAuthKey() === $authKey;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question