protected function prepareBody(SignupForm $model, Users $users) { $placeholders = $users->toArray(); $placeholders['password'] = $model->password; if ($model->generateToken) { $placeholders['url'] = Url::set($this->activateUrl)->addArgs(['token' => $placeholders['token']])->getAbsolute(); } return $this->template->getChunk($this->emailBodyTpl, $placeholders); }
/** * Finds user by `email` * * @return Users */ protected function getUsers() { if (!isset($this->users)) { if (!($this->users = Users::findOneByEmail($this->email, Users::STATUS_ACTIVE, false))) { $this->addError('alerts', i18n::t('invalidEmail')); } } return $this->users; }
public function afterSignup() { if (!($users = Users::create($this->getAttributes(), $this->defaultStatus, $this->generateToken))) { $this->addError('alerts', i18n::t('failSignup')); return; } $this->users = $users; $this->users->id = $this->users->primaryKey; $event = new ModelEvent(); $event->result = $users; $this->trigger(self::EVENT_AFTER_SIGNUP, $event); }
public function actionIndex(User $user, Session $session) { $placeholders = []; if ($session->hasFlash($this->keySessionFlash)) { $placeholders['content'] = i18n::t('successActivate'); return $this->render('success', $placeholders); } elseif ($user->isGuest() && ($users = Users::activate(Request::get('token')))) { // auto-login $user->addMulti($users->toArray(['id', 'username', 'url'])); $user->login(); $session->setFlash($this->keySessionFlash); $this->response->redirect(Url::set()->removeAllArgs()->getAbsoluteUrl(true))->send(true); return null; } return $this->notPage('@frontend.views/layouts/notPage'); }
/** * Finds user by `email`. * * @return Users */ public function getUsers() { if (!isset($this->users)) { if (!($this->users = Users::findOneByEmail($this->email, null, false))) { $this->addError('alerts', i18n::t('notExistsUser')); } } return $this->users; }
protected function login(User $user, Users $users) { $data = $users->toArray(); $user->addMulti(ArrayHelper::intersectByKeys($data, ['id', 'username', 'url'])); $user->login(); }
protected function prepareBody(Users $users) { return $this->template->getChunk($this->emailBodyTpl, $users->toArray()); }