/** * Register action : create a new account * @access public * @return void */ public function register() { $this->form = new UserCreateForm(); if ($this->request->is_post()) { if (!$this->form->is_valid($this->params['account'])) { $this->flash['error'] = __('Fail to create account : Check data.'); return; } $this->user = new User($this->form->cleaned_data); if (!$this->user->save()) { $this->form->errors = new SFormErrors($this->user->errors); $this->flash['error'] = __('Fail to create account : Check data.'); return; } $logger = new SLogger('../log/account.log'); $logger->info("{$this->user->login} ({$this->user->id}) signup"); $this->session['user'] = $this->user; $mailer = new ApplicationMailer(); $mailer->send_signup_notification($this->user); $this->redirect_to(home_url()); } }
/** * Lost action : if user has lost his password * @access public * @return void */ public function lost() { $this->form = new LostLoginForm(); $req = new SRequestParams(); if ($this->request->is_post()) { if ($this->form->is_valid($this->params['user'])) { try { $user = User::$objects->get('email = ?', array($this->params['user']['email'])); $mailer = new ApplicationMailer(); $mailer->send_password_reminder($user); $logger = new SLogger('../log/account.log'); $logger->info("{$user->login} ({$user->id}) password reminder sent to <{$user->email}>"); $this->flash['notice'] = __('Password reminder has been sent to you by email'); $this->redirect_to_login(); return; } catch (SRecordNotFound $e) { $this->flash['error'] = __('This email address is not registered'); $this->form->errors = new SFormErrors(array('email' => __('Email not found'))); return; } } $this->flash['error'] = __('You have to give a valid registered email address.'); } }