Answer the question
In order to leave comments, you need to log in
Pass user id on registration to token table?
There are two tables (models) user and token. User data is stored in user, id, email, username, etc., and in token, email confirmation tokens, password changes.
There is a RegistrationForm layer model, with a function for registration:
public function registration()
{
if (!$this->validate()) {
return null;
}
$user = new User();
$user->nickname = $this->nickname;
$user->email = $this->email;
$user->setPassword($this->password);
$user->generateAuthKey();
/.....
return $user->save() ? $user : null;
}
public function createEmailConfirmToken()
{
$token = new Token();
$token->code = Yii::$app->security->generateRandomString();
$token->created_at = time();
$token->type = Token::CONFIRMATION_EMAIL;
return $token->save() ? $token : null;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question