/** * Generates a new random password and then send it via email to the user. */ public function actionResetPassword() { $model = new ResetPasswordForm(); $success = false; $email = ''; if (isset($_POST['ResetPasswordForm'])) { $model->attributes = $_POST['ResetPasswordForm']; $this->performAjaxValidation($model); $user = User::model()->findByAttributes(array('email' => $model->email)); if (isset($user)) { $email = $user->email; $password_clear = UserHelper::generateRandomPassword(); $user->password = $user->changeAccountPassword($password_clear); if ($user->save()) { /* write an INFO syslog */ BasicNotifier::sendTemplatedEmail($user->email, Yii::t('UsersModule.resetPassword', 'email.subject'), 'users/account_reset_password', array('{USER_PASSWORD}' => $password_clear), Yii::app()->session['lang']); $success = true; } } } $this->render('resetPassword', array('model' => $model, 'success' => $success, 'email' => $email)); }
public function control_efetuar_cadastro() { $this->titulo = 'Cadastre-se'; if ($this->isPostRequest) { $senhaTemporaria = UserHelper::generateRandomPassword(); try { $d = new Usuarios($_POST); $this->em->persist($d); $this->em->flush(); } catch (Exception $ex) { $this->adicionarMensagemErro('Ocorreu um erro com seu cadastro, por favor verifique todos os campos'); $this->adicionarMensagemErro($ex->getMessage()); return $this->renderizar('cadastro', array('usuario' => $d)); } $this->mailer->enviaEmail(array('Usuário' => $d->getEmail(), 'Senha' => $_POST['senha'], 'nome' => $d->getNome()), $d->getEmail(), 'Seja bem vindo(a) ' . $d->getNome(), 'email_pos_cadastro'); return $this->redirect('cadastro-sucesso/'); } return $this->redirect('home'); }