/** * @return bool */ public function login() { if ($this->validate()) { return User::login($this->email, $this->remember_me); } return false; }
/** * @throws \yii\base\Exception * @throws \yii\base\InvalidConfigException */ public function register() { if (!$this->validate()) { return false; } $user = new User(); $user->email = $this->email; $user->name = $this->name; $user->country_id = $this->country_id; $user->phone = $this->phone; $user->address = $this->address; $user->password_hash = User::hashPassword($this->password); $user->generateAuthKey(); $user->status = User::USER_STATUS_ACTIVE; $user->save(); return User::login($this->email, true); }